Advertisement
Guest User

Untitled

a guest
Oct 16th, 2013
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.97 KB | None | 0 0
  1. <?php
  2. $name = $_POST['name'];
  3. $email = $_POST['email'];
  4. $message = $_POST['message'];
  5. $subject = "New Message";
  6.  
  7.  
  8. mail($to, $subject, $message, "From: " .$name);
  9. echo $name.$email.$message;
  10.  
  11.  
  12. if (isset($_POST['submit']))
  13. {
  14. $boolValidateOK = 1;
  15. $strValidationMessage = "";
  16.  
  17. //Validating Name
  18. if(strpos($name, ' ') == false)
  19. {
  20. $ValidateOK = 0;
  21. $strValidationMessage .= "\nName is Required!.<br />";
  22. }
  23.  
  24. //Validating Message
  25. if(strpos($message, ' ') == false)
  26. {
  27. $ValidateOK = 0;
  28. $strValidationMessage .= "\nMessage is Required!.<br />";
  29. }
  30.  
  31. //Function Of the Email Address
  32. function validate_email( $senderemail )
  33. { // this is a function; it receives info and returns a value.
  34. $email = trim( $senderemail ); # removes whitespace
  35. if(!empty($email) ):
  36. // validate email address syntax
  37. if( preg_match('/^[a-z0-9\_\.]+@[a-z0-9\-]+\.[a-z]+\.?[a-z]{1,4}$/i', $email, $match) ):
  38. return strtolower($match[0]); # valid!
  39. endif;
  40. endif;
  41. return false; # NOT valid!
  42. }// end function validate_email
  43.  
  44. //Valadating Email Address
  45. $emailValidate = validate_email($email);
  46. if(!$emailValidate)
  47. {
  48. $boolValidateOK = 0;
  49. $strValidationMessage .= "\nEmail Address is Required.<br />";
  50. }
  51.  
  52. // This will protect you from Security against email spams
  53. $badStrings = array("Content-Type:",
  54. "MIME-Version:",
  55. "Content-Transfer-Encoding:",
  56. "bcc:",
  57. "cc:");
  58. foreach($_POST as $k => $v){
  59. foreach($badStrings as $v2){
  60. if(strpos($v, $v2) !== false){
  61. // In case of spam, all actions taken here
  62. //header("HTTP/1.0 403 Forbidden");
  63. //exit; // stop all further PHP scripting, so mail will not be sent.
  64.  
  65. $boolValidateOK = 0;
  66. $strValidationMessage = "There is a security problem with the formatting of this message. ";
  67. $strValidationMessage .= "Please try again.";
  68. }
  69. }
  70. }
  71.  
  72. if($boolValidateOK == 1)
  73. {
  74. $strValidationMessage = "Email Has been Sent.";
  75. }
  76.  
  77. }//End If
  78. ?>
  79. <html>
  80. <head>
  81. <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
  82. <meta name="kewords" content="Rawad Merhi,Computer Service, Computer Business, RMCS,hardware,software installation,blue screen" />
  83. <link rel="stylesheet" type="text/css" href="assets/css/style.css">
  84. <link rel="shortcut icon" href="assets/images/favicon.ico">
  85. </head>
  86. </head>
  87.  
  88. <body>
  89. <div class ="container">
  90. <header></header>
  91. <nav>
  92. <ul>
  93. <li><a href="contact.php">Contact</a></li>
  94. <li><a href="service.html">Services</a></li>
  95. <li><a href="index.html">Home</a></li>
  96. </ul>
  97. </nav>
  98.  
  99. <div class="mainContent">
  100. <div class="form_Wrapper">
  101. <form name="contactform"id="contactform" method="post" action="contact.php">
  102.  
  103. <p>
  104. <label for="name">Your Name:</label><br>
  105. <input type="text" name="name" id="name" value = "<?php echo $name?>"/>
  106. </p>
  107.  
  108. <p>
  109. <label for="email">Your Email:</label><br>
  110. <input type="text" name="email" id="email" value = "<?php echo $email?>"/>
  111. </p>
  112.  
  113. <p>
  114. <label for="message">Your Message:</label><br>
  115. <textarea name="message" name="message" id="message" value = "<?php echo $message?>"/></textarea>
  116. </p>
  117.  
  118. <input type="submit" name="submit" value="Send Message" class="btn">
  119.  
  120. <div id="formvalidate">
  121. <?php
  122. echo $strValidationMessage;
  123. ?>
  124. </div>
  125.  
  126. </form>
  127. </div>
  128.  
  129. </div><!--Close Main Content-->
  130.  
  131. <footer>
  132.  
  133. <a href="http://www.linkedin.com/profile/view?id=235080087&goback=%2Enmp_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1&trk=spm_pic"><img src="assets/images/linkedin.png"class="icon"></a>
  134.  
  135. <a href="https://twitter.com/Rawad_Merhi/"><img src="assets/images/twitter.png"class="icon"></a>
  136.  
  137. <a href="https://www.facebook.com/RawadHomeComputerService"><img src="assets/images/facebook.png"class="icon"></a>
  138.  
  139. <p>&copy; Rawad Home Computer Service 2012</p>
  140. </footer>
  141. </div>
  142.  
  143.  
  144. </body>
  145. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement