Ok so I am trying to get my form to update my table to edit a contact but for some reason with 0 errors it just won't update and I just can not figure out why as it all looks good to me.
Here is the edit contact script
// Connect to database
$dbc = mysql_connect("localhost", "root");
if (!$dbc)
die("Could not connect: " . mysql_error());
// Select database
$db_select = mysql_select_db( "contactmanager", $dbc );
if (!$db_select)
die("Could not select DB: " . mysql_error());
// Build update function for form
if(isset($_POST['update'])){
mysql_query("UPDATE contacts SET Name='$_POST[name]', Address='$_POST[address]', Phone='$_POST[phone]', Mobile='$_POST[mobile]', Email='$_POST[email]' WHERE ContactID = $contactID") or trigger_error(mysql_error());
echo 'Update has been pushed and fucntion has run';
} else {
echo 'Update has not been pushed.';
}
// initialize form control values
$name = '';
$address = '';
$phone = '';
$mobile = '';
$email = '';
// Get ID of contact selected for editing
$contactID = $_GET['id'];
// build sql select statement
$query = "SELECT * FROM contacts WHERE ContactID = '$contactID'";
// Run sql statement against database
$result = mysql_query($query, $dbc);
if ($result) {
$row = mysql_fetch_assoc($result);
$name = $row["Name"];
$address = $row["Address"];
$phone = $row["Phone"];
$mobile = $row["Mobile"];
$email = $row["Email"];
}
else {
// If there is an error display message
echo '<p><b class="error">Error with $rst: ' . mysql_error($dbc) . '</b></p>';
}
?>
<form name="editcontact" method="post" action="edit-contact.php" id="editcontact">
<fieldset>
<dl>
<dt><label for="name">Name</label></dt>
<dd><input name="name" type="text" value="<?php echo $name; ?>" size="33" maxlength="50" tabindex="1" /></dd>
</dl>
<dl>
<dt><label for="address">Address</label></dt>
<dd><textarea name="address" cols="33" rows="5" tabindex="2"><?php echo $address; ?></textarea></dd>
</dl>
<dl>
<dt><label for="phone">Phone</label></dt>
<dd><input name="phone" value="<?php echo $phone; ?>" type="text" size="33" maxlength="50" tabindex="3" /></dd>
</dl>
<dl>
<dt><label for="mobile">Mobile</label></dt>
<dd><input name="mobile" value="<?php echo $mobile; ?>" type="text" size="33" maxlength="50" tabindex="4" /></dd>
</dl>
<dl>
<dt><label for="Email">Email</label></dt>
<dd><input name="email" value="<?php echo $email; ?>" type="text" size="33" maxlength="50" tabindex="5" /></dd>
</dl>
<dl>
<dt></dt>
<dd><input type="submit" value="Update" name="update" tabindex="6" style="margin-left:7.3%;" /></dd>
<dd><a href="list-contacts.php" alt="Contacts List"><p style="margin-left:7.3%;">Back to contacts list</p></a></dd>
</dl>
</fieldset>
</form>
<?php
?>