Ich möchte ein php Programm schreiben, der ein Formular mit eine Dropdown Liste darstellt und dann entsprechend der gewählte Option eine Funktion mit entsprechenden Parameter aufruft. Das ganze dient dazu ein ExcelDump bestimmter Felder einer MySQL Tabelle abhängig vom Wert eines Feldes zu generieren und auf der HD zu speichern.
Bisher bin ich soweit gekommen, aber ich möchte nicht für jede Option ein neues HTML schreiben, aber nur eine Funktion mit Parameterübergabe nutzen, weiss aber nicht wie ich Funktionen im Formular aufrufen kann ....
Kann mir jemand auf die Sprünge helfen?
PHP-Code:
PHP-Code:
<!DOCTYPE*HTML*PUBLIC*"-//W3C//DTD*HTML*4.01*Transitional//EN"*"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>PHP*form*select*box*</title>
<!--*some*style*elements-->
<style>
label,a
{
font-family*:*Arial,*Helvetica,*sans-serif;
font-size*:*12px;
}
</style>
</head>
<body>
<?php
if(isset($_POST['formSubmit']))
{
$varCountry*=*$_POST['formCountry'];
$errorMessage*=*"";
if(empty($varCountry))
{
$errorMessage*=*"<li>You*forgot*to*select*a*country!</li>";
}
if($errorMessage*!=*"")
{
echo("<p>There*was*an*error*with*your*form:</p>\n");
echo("<ul>"*.*$errorMessage*.*"</ul>\n");
}
else
{
$redir*=*"US.html";
switch($varCountry)
{
case*"US":*$redir*=*"US.html";*break;
case*"UK":*$redir*=*"UK.html";*break;
case*"France":*$redir*=*"France.html";*break;
case*"Mexico":*$redir*=*"Mexico.html";*break;
case*"Russia":*$redir*=*"Russia.html";*break;
case*"Japan":*$redir*=*"tabledump()";*break;
default:*echo("Error!");*exit();*break;
}
echo*"*redirecting*to:*$redir*";
exit();
}
}
?>
<form*action="<?php*echo*htmlentities($_SERVER['PHP_SELF']);*?>"*method="post">
<label*for='formCountry'>Select*your*country*of*residence</label><br>
<select*name="formCountry">
<option*value="">Select*a*country...</option>
<option*value="US">United*States</option>
<option*value="UK">United*Kingdom</option>
<option*value="France">France</option>
<option*value="Mexico">Mexico</option>
<option*value="Russia">Russia</option>
<option*value="Japan">Japan</option>
</select>
<input*type="submit"*name="formSubmit"*value="Submit"*/>
</form>
</body>
</html>