Advertisement
Guest User

Untitled

a guest
Aug 30th, 2015
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. <?php
  2.  
  3. ini_set('display_errors',1);
  4. error_reporting(E_ALL|E_STRICT);
  5.  
  6. // -----------------------------------------
  7. // The Web Help .com
  8. // -----------------------------------------
  9. // remember to replace you@email.com with your own email address lower in this code.
  10.  
  11. // load the variables form address bar
  12. $subject = $_POST["subject"];
  13. $message = $_POST["message"];
  14. $from = $_POST["from"];
  15. $verif_box = $_POST["verif_box"];
  16.  
  17. // remove the backslashes that normally appears when entering " or '
  18. $message = stripslashes($message);
  19. $subject = stripslashes($subject);
  20. $from = stripslashes($from);
  21.  
  22. // check to see if verificaton code was correct
  23. if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
  24. // if verification code was correct send the message and show this page
  25. mail("abhijit.infogence@gmail.com", 'TheWebHelp.com Form: '.$subject, $_SERVER['REMOTE_ADDR']."nn".$message, "From: $from");
  26. // delete the cookie so it cannot sent again by refreshing this page
  27. setcookie('tntcon','');
  28. } else if(isset($message) and $message!=""){
  29. // if verification code was incorrect then return to contact page and show error
  30. header("Location:".$_SERVER['HTTP_REFERER']."?subject=$subject&from=$from&message=$message&wrong_code=true");
  31. exit;
  32. } else {
  33. echo "no variables received, this page cannot be accessed directly";
  34. exit;
  35. }
  36. ?>
  37.  
  38. <form method="POST" action="yourfile.php">
  39. etc.
  40. </form>
  41.  
  42. print_r($_POST);
  43. print_r($_COOKIE);
  44.  
  45. foreach(array('subject', 'message', 'from', 'verif_box') as $val)
  46. {
  47. if (isset($_POST[$val]))
  48. {
  49. $$val = trim($_POST[$val]);
  50. continue;
  51. }
  52.  
  53. // some sort of error checking, like telling the end user that
  54. // not all fields were correctly given
  55. }
  56.  
  57. $subject = (isset($_POST["subject"]) ? $_POST["subject"] : '');
  58. $message = (isset($_POST["message"]) ? $_POST["message"] : '');
  59. $from = (isset($_POST["from"]) ? $_POST["from"] : '');
  60. $verif_box = (isset($_POST["verif_box"]) ? $_POST["verif_box"] : '');
  61.  
  62. function checkPost($fieldname)
  63. {
  64. return (isset($_POST[$fieldname]) ? $_POST[$fieldname] : '');
  65. }
  66.  
  67. $subject = checkPost("subject");
  68.  
  69. if (!isset($_POST["xxx"]) || trim($_POST["xxx"]) == '')
  70. {
  71. // throw exception, display error...
  72. }
  73.  
  74. //checking if array elements are set and changing variables values if so
  75. $subject = isset($_POST["subject"])?$_POST["subject"]:null;
  76. $message = isset($_POST["message"])?$_POST["message"]:null;
  77. $from = isset($_POST["from"])?$_POST["from"]:null;
  78. $verif_box = isset($_POST["verif_box"])?$_POST["verif_box"]:null;
  79.  
  80. // check to see if verificaton code was correct and if cookie value on 'tntcon' is set
  81. if(isset($_COOKIE['tntcon']) && md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement