I copied this code from some forms that work and changed some information to apply to the new situation but something is wrong. The form "editreg.php" seems to be working fine. It populates the fields correctly. When it gets redirected to "editregsubmit.php" I get the message that the record was updated but when I check the table or refresh the form the record was NOT updated. What am I doing wrong? Eventually I want to only show the fields Camps, Grades, Dates, and Cost and only update the Number field. I do not want the id field to show at all. I am just including these as they are so I can troubleshoot, but this obviously isn't working. Can someone explain why?
editreg.php:
<?php
$con = mysql_connect("","pleasant_pbc","***");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("pleasant_pbc", $con);
mysql_query($sql,$con);
$data = 'SELECT * FROM reg WHERE id = "1"';
$query = mysql_query($data) or die("Couldn't execute query. ". mysql_error());
$data2 = mysql_fetch_array($query);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
</head>
<body>
<!-- form to display record from database -->
<form name="form" method="POST" action="editregsubmit.php">
<input type="text" name="number" size="2" value="<?php echo $data2[id]?>" />
Camp: <input type="text" name="camp" value="<?php echo $data2[camp]?>" />
Grades: <input type="text" name="grades" value="<?php echo $data2[grades]?>" />
Dates: <input type="text" name="dates" value="<?php echo $data2[dates]?>" />
Cost: <input type="text" name="cost" value="<?php echo $data2[cost]?>" />
Number Registered: <input type="text" name="number" value="<?php echo $data2[number]?>" size="5"/>
<input type="submit" value="submit" />
</form>
</body>
</html>
As I said, this form populates correctly.
editregsubmit.php:
<?php
$con = mysql_connect("","pleasant_pbc","***");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("pleasant_pbc", $con);
$id=$_POST['id'];
$camp=$_POST['camp'];
$grades=$_POST['grades'];
$dates=$_POST['dates'];
$cost=$_POST['cost'];
$number=$_POST['number'];
$data = "UPDATE reg SET id='$id', camp='$camp', grades='$grades', dates='$dates', cost='$cost', number='$number' WHERE id=".'"'.$id.'"';
$query = mysql_query($data) or die("Couldn't execute query. ". mysql_error());
echo "record update complete";
?>