Skip to content

Instantly share code, notes, and snippets.

@walterdavis
Created May 30, 2009 13:54
Show Gist options
  • Save walterdavis/120506 to your computer and use it in GitHub Desktop.
Save walterdavis/120506 to your computer and use it in GitHub Desktop.
if(isset($_POST['save'])){
$person->populate(clean($_POST));
$person->save();
if(!$person->get_errors()){
//everything has been saved
//send two mail messages
mail(ADMIN_EMAIL,'New contact from the Web site',print_r($person,true),'From: ' . ADMIN_EMAIL,'-f' . ADMIN_EMAIL);
mail($person->email,AUTOREPLY_SUBJECT,AUTOREPLY_MESSAGE,'From: ' . ADMIN_EMAIL,'-f' . ADMIN_EMAIL);
//redirect
header('Location: ' . THANKS_PAGE);
}else{
//make a list of errors
$errors = '<ul class="errors">';
foreach($person->get_errors() as $e) $errors = '<li>' . $e . '</li>';
$errors = '</ul>';
//print these out later in your page with <?=$errors?>
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment