Advertisement
Guest User

Untitled

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