This code is suppose to ask for how many drivers were in a race, then load a page that has that many drop down boxes. From there you should be able to hit submit and the script should update the database based on who finished where in the race. The problem seems to be that as soon as you hit submit to update the database (2nd part of the script) it loops back to the page where you enter how many drivers were in the race and the database never gets updated. Any ideas as to why this is happening? TIA!
(Link to script: http://sql.3dvault.net/Large_test1.php)
<HTML>
<BODY background="bkgrd.gif">
<div align="center"><font color="#00FF00" face="BankGothic Md BT">
<?PHP
if(isset($POST['submitted2'])) {
$players = $POST['driver_number'];
//$players = 20;
$conn = mysql_connect("localhost","vault_read")or die(mysql_error());
mysql_select_db("vault_gpl",$conn)or die(mysql_error());
echo "<HTML>";
echo "<HEAD><TITLE> TEST </TITLE>";
echo "</HEAD>";
echo "<BODY BGCOLOR=\"black\" background=\"bkgrd.gif\">";
if(isset($_POST['submitted'])) {
$first = $_POST['Driver_1'];
$second = $_POST['Driver_2'];
$third = $_POST['Driver_3'];
$fourth = $_POST['Driver_4'];
$fifth = $_POST['Driver_5'];
$sixth = $_POST['Driver_6'];
mysql_query("UPDATE d_points SET driver_points = (driver_points + 8) WHERE driver_id = '$first'") OR DIE (mysql_error());
mysql_query("UPDATE d_points SET driver_points = (driver_points + 6) WHERE driver_id = '$second'") OR DIE (mysql_error());
mysql_query("UPDATE d_points SET driver_points = (driver_points + 4) WHERE driver_id = '$third'") OR DIE (mysql_error());
mysql_query("UPDATE d_points SET driver_points = (driver_points + 3) WHERE driver_id = '$fourth'") OR DIE (mysql_error());
mysql_query("UPDATE d_points SET driver_points = (driver_points + 2) WHERE driver_id = '$fifth'") OR DIE (mysql_error());
mysql_query("UPDATE d_points SET driver_points = (driver_points + 1) WHERE driver_id = '$sixth'") OR DIE (mysql_error());
exit();
}else{
echo "<div align=\"center\"><font color=\"#00FF00\" face=\"BankGothic Md BT\">\n";
echo "<FORM METHOD=\"POST\" ACTION=\"$SERVER[PHP_SELF]\">\n";
echo "<P>\n";
//echo "1.\n<P>\n";
$b = 0;
$place = 1;
//echo $place . "<P>";
//$place ++;
for($a = 1; $a <= $players; $a++) {
echo $place . "." . "\n<P>\n";
$place ++;
echo "<SELECT NAME=\"Driver_" . $a . "\">\n";
echo "<OPTION NAME=\"\"></OPTION>\n";
$result = "SELECT * FROM d_points ORDER BY driver_id ASC";
$sqlres = mysql_query($result)or die(mysql_error());
while ($row = mysql_fetch_array($sqlres)) {
echo "<OPTION VALUE=\"" . $row['driver_id'] . "\">" . $row['driver_name'] . "</OPTION>\n";
}
echo "</SELECT>\n";
echo "<P>\n";
//echo $place . ".   <P>\n";
$b++;
//$place ++;
}
echo "<INPUT TYPE=\"hidden\" NAME=\"submitted\">\n";
echo "<INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"submit\">\n";
echo "</FORM>\n";
echo "</DIV></FONT>\n";
echo "</BODY>";
echo "</HTML>";
}
}
else
{
echo "<FORM method=\"post\" action=\"$SERVER[PHP_SELF]\">";
echo "Number Of Drivers:";
echo "<INPUT type=\"text\" name=\"driver_number\">";
echo "<P>";
echo "<INPUT type=\"hidden\" name=\"submitted2\">";
echo "<INPUT type=\"submit\" name=\"submit2\">";
echo "</FORM>";
echo "</font></div>";
echo "</body>";
echo "</html>";
}
?>