Advertisement
Guest User

Untitled

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