I am trying to update a table.
Firstly, I am GETting a value passed and putting it into $ID.
Then I am passing a value from a form and attempting to UPDATE the email column in a table with that value, only WHERE the row has the same value as $ID in the id column.
My table looks like this
ID NAME EMAIL
1 name1 email1
2 name2 email2
When I enter a value into the text box, and hit submit, I get the 'Thank you' message, however the table has not been updated 🙁
If anyone can spot what im doing wrong id appreciate it 🙂
Thanks
and here is my code....
<?
$id=$_GET['id'];
echo "The ID passed is $id";
/* declare some variables */
$DBhost = "localhost";
$DBuser = "odbc";
$DBpass = "";
$DBName = "drivers";
$table = "drivers";
/* CORRECTION */
$submit = $_POST['submit'];
if ($submit) {
/* connect to database */
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");
mysql_select_db("$DBName") or die("Unable to select database $DBName");
$temp = $_POST["email"];
$sql = "UPDATE $table SET email=$temp WHERE id=$id ";
/* CORRECTION */
mysql_query($sql);
echo "Thank you";
} else{
// display form
?>
<FORM action="" method="POST" name="Form1">
<b>Email:</b><input type="text" size="40" name="email">
<input type="submit" value="submit" name="submit">
</form>
<?
} // end if
?>