Bij deze code wordt steeds het eerste if-statement uitgevoerd, ook al
is de ($_GET["plekje"])waarde niet overeenkomsitg :s .
Dit is de code :
<?php
// variabelen initialiseren:
include("dogs.inc"); #11
$connection = mysql_connect($host,$user,$password) #13
or die ("couldn't connect to server");
$db = mysql_select_db($database,$connection) #15
or die ("Couldn't select database");
if (empty($_POST)){
// eerst controleren of pagina wel is aangeroepen vanuit formulier
echo("Vul eerst <a href=\"fromtoevoegenstanden.html\">gegevens
voor de werknemer</a> in");
exit();
}else{
if ($_GET["plekje"] =="één")
{
$stand =$_POST['fstand'];
$datum =$_POST['fdatum'];
$sql="INSERT INTO water1 (stand,datum)
VALUES ('$stand','$datum')";
mysql_query($sql) or die ("can't execute query.");
}
elseif ($_GET["plekje"] == "twee")
{
$stand =$_POST['fstand'];
$datum =$_POST['fdatum'];
$sql="INSERT INTO water2 (stand,datum)
VALUES ('$stand','$datum')";
mysql_query($sql) or die ("can't execute query.");
}
elseif ($_GET['plekje'] == "drie")
{
$stand =$_POST['fstand'];
$datum =$_POST['fdatum'];
$sql="INSERT INTO water1 (stand,datum)
VALUES ('$stand','$datum')";
mysql_query($sql) or die ("can't execute query.");
}
}
?>
Dus wanneer de ($_GET['plekje']) waarde gelijk is aan drie, wordt toch
de eerste if-statement uitgevoerd.
817 views