My visitors have to submit a form. Every 50th submitter will receive a present. The 50th will get the message:"Congratulations! You are user number 50." All other users get:"Unfortunately, you are number ..."
I coded it like below, but it doesn't work.
Can anyone see where my mistake is?
<?php
if ($submit == "VERSTUUR"){
$connection=mysql_connect ("localhost","indianpearls","");
if ($connection==false){
echo mysql_errno().": ".mysql_error()."<br>";
exit;
}
$query="insert into deelnemer (nr, fname, lname, geslacht, adres, postcode, plaats, email, item, datum) values ('$nr','$fname','$lname','$geslacht','$adres','$postcode','$plaats','$email','$item',NOW())";
$result=mysql_db_query ("indianpearls_nl_db",$query);
$dothis = "select count(*) from deelnemer";
$result = mysql_db_query("indianpearls_nl_db",$dothis);
$number = mysql_num_rows($result);
if (!$number%50){
echo "Congratulations! You are user number $number[0].<br>";
echo "You will receive your present within the next 8 days.<br>";
}
else{
echo "Unfortunately, you are user number $number[0].<br>";
echo "Please try again soon.<br>";
}
else{
echo mysql_errno().": ".mysql_error()."<br>";
}
mysql_close();
}
else{
echo '
<body bgcolor="#FF9966">
<form method="post" action="testform.php">
<table border="0" width="100%">
<tr>
<td width="19%">Voornaam:</td>
<td width="81%"><input type="text" name="fname" size="25"></input></td>
</tr>
<tr>
<td width="19%">Achternaam:</td>
<td width="81%"><input type="text" name="lname" size="25"></input></td>
</tr>
<tr>
<td width="19%">Geslacht:</td>
<td width="81%"><input type="radio" name="geslacht" value="man">man <input type="radio" name="geslacht" value="vrouw">vrouw</input></td>
</tr>
<tr>
<td width="19%">Adres:</td>
<td width="81%"><input type="text" name="adres" size="25"></input></td>
</tr>
<tr>
<td width="19%">Postcode:</td>
<td width="81%"><input type="text" name="postcode" size="25"></input></td>
</tr>
<tr>
<td width="19%">Woonplaats:</td>
<td width="81%"><input type="text" name="plaats" size="25"></input></td>
</tr>
<tr>
<td width="19%">E-mail:</td>
<td width="81%"><input type="text" name="email" size="25"></input></td>
</tr>
<tr>
<td width="19%">DVD titel:</td>
<td width="81%"><input type="text" name="item" size="25"></input></td>
</tr>
</table>
<p>
<input type="submit" name="submit" value="VERSTUUR"></input>
</p></form>
</body>
';
}
?>

