0)) {
# id to edit
$editid = $_REQUEST['id'];
# grab info
$query = "SELECT contact_name,business_name FROM contact WHERE id='".mysql_real_escape_string($editid)."'";
$result = mysql_query($query);
if((!$result) || (@mysql_num_rows($result) < 1)) {
die('That ID does no exist');
}
else {
$row = mysql_fetch_object($result);
?>
0)){
# id to edit
$editid = $_REQUEST['id'];
// check for errors
$err = false; // currently, there is no errors.
$errmsg = 'Error
';
// empty error msg. msg with no current errors.
// check to see if content field is empty or not. if so, make error.
if(empty($_POST['contact_name'])){
$err = true; // there is now an error.
$errmsg .= 'Content is a required field and must be filled out.
'; // append an error msg to the end of $errmsg
}
// if there's an error ( $err = true ), let them know and exit.
if($err) { echo $errmsg; exit; }
if(!$err){ // if no errors, do the foloowing
// store the fields into an easier writeable variable. so you dont have to type $_POST[''] to use it everytime.
$contact_name = $_POST['contact_name'];
$business_name = $_POST['business_name'];
//connect to the mysql server
//insert the new info into the database
$query = "update contact set contact_name='". $contact_name ."',
business_name='". $business_name ."' where id = '".mysql_real_escape_string($editid)."'";
$result = mysql_query($query) or die(mysql_error());
echo ' return ';
}
} // close if action = update brace
?>