Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

kilian site.php (part)

a guest Aug 8th, 2014 77 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. /**
  2.  * Contact page
  3.  */
  4. Route::post('contact', function() {
  5.  
  6.     $input = Input::get(array('contact-subject', 'contact-name', 'contact-email', 'contact-message', 'contact-math'));
  7.  
  8.     // Validator check...
  9.     $validator = new Validator($input);
  10.  
  11.     $validator->check('contact-subject')
  12.         ->is_max(1, "Subject is required!");
  13.  
  14.     $validator->check('contact-name')
  15.         ->is_max(2, "Name is required!");
  16.  
  17.     $validator->check('contact-email')
  18.         ->is_email("Email is required!");
  19.  
  20.     $validator->check('contact-message')
  21.         ->is_max(5, "Message is empty or too short!");
  22.  
  23.     $validator->check('contact-math')
  24.         ->is_answer(Session::get('contact-math-session'), "Wrong math answer!!!");
  25.  
  26.     if($errors = $validator->errors()) {
  27.         Input::flash();
  28.         Notify::error($errors);
  29.         return Response::redirect('contact#error');
  30.     }
  31.  
  32.     $me = "tobias.abeling@gmx.net"; // Your email address
  33.     $subject = $input['contact-subject'];
  34.     $message = $input['contact-message'];
  35.  
  36.     $header  = "From: " . $input['contact-email'] . " \r\n";
  37.     $header .= "Reply-To: " . $input['contact-email'] . " \r\n";
  38.     $header .= "Return-Path: " . $input['contact-email'] . "\r\n";
  39.     $header .= "X-Mailer: PHP \r\n";
  40.  
  41.     if(mail($me, $subject, $message, $header)) {
  42.         Notify::success("Email sent!");
  43.         return Response::redirect('contact#sent');
  44.     } else {
  45.         Notify::error("Failed to send email!");
  46.         return Response::redirect('contact#failed');
  47.     }
  48.  
  49. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top