Advertisement
Guest User

Untitled

a guest
Jan 25th, 2017
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. <?php
  2. if(!isset($_POST['name']))
  3. {
  4. //This page should not be accessed directly. Need to submit the form.
  5. echo "error; you need to submit the form!";
  6. die();//header("location:index.html");//you can change later
  7. }
  8.  
  9. //echo '<pre>'.print_r($_POST,1); exit; //comment this line to continue
  10. $name = $_POST['name'];//remember.. name not using capitalize
  11. $email_address = $_POST['email_address'];
  12. $phone = $_POST['phone'];
  13. $comments = $_POST['comments'];
  14. // better using read able name.. above is fine.. but using capitalize name whould be hard to type, I understand that so I should LC all of it. but also make suret the values match the form names right?
  15. //Validate first
  16. if(empty($name)||empty($email_address)) //$visitor_EMAIL_ADDRESS is not valid.. but you should check this should type $EMAIL_ADDRESS
  17. {
  18. echo "Name and email are mandatory!";
  19. //the email will not be empty... but you need to check if the email is valid
  20. // http://stackoverflow.com/questions/12026842/how-to-validate-an-email-address-in-php
  21. exit;
  22. }
  23.  
  24. $email_from = 'karljames@verizon.net';//'kjames1973@gmail.com';//<== Put your email address here
  25. $email_subject = "New Form submission";
  26. $email_body = "You have received a new message from the user $name.\n".
  27. "email address: {$email_address}\n".
  28. "Here is the COMMENTS:\n $comments";
  29.  
  30. $to = "karljames@verizon.net"; //"karljames@verizon.net";//<== Put your email address here
  31. //$headers = "From: $email_from \r\n";
  32. $headers .= "From: {$email_from}\r\n";
  33. $headers .= "Reply-To: {$email_from}\r\n";
  34. $headers.= "MIME-Version: 1.0\r\n";
  35. $headers.= "Content-Type: text/plain; charset=ISO-8859-1\r\n";
  36. //$header.= "X-Priority: 1\r\n";
  37. /*
  38. $headers = "From: noreply@salmaforex.com\r\n";
  39. $headers .= "Reply-To: noreply@salmaforex.com\r\n";
  40. $headers .= "MIME-Version: 1.0\r\n";
  41.  
  42. $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
  43. */
  44. //Send the email!
  45. mail($to, $email_subject, $email_body,$headers);
  46. //mail($to, $email_subject."(2)", $email_body );
  47. echo "<br/>SUCCESS";
  48. //this email function not always work as we wanted
  49.  
  50. /*
  51. for first.. hope this mail work
  52. if not.. search how to using SMTP or other ways to email...
  53. */
  54. //done. redirect to thank-you page.
  55. //die("success<pre>".print_r($_SERVER,1));
  56. //header('Location: thank-you.html'); //try not using header...
  57. //using js goto
  58. // http://stackoverflow.com/questions/9803978/javascript-method-to-navigate-to-other-url
  59.  
  60. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement