Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (isset($_POST['submit']))
- {
- $name = $_POST['name'];
- $email = $_POST['email'];
- $message = $_POST['message'];
- $ to = "rh_cs@outlook.com";
- $subject = "New Message";
- $strValidationMessage = "";
- mail($to, $subject, $message, "From: " .$name);
- $boolValidateOK = 1;
- $strValidationMessage = "";
- //Validating Name
- if(strpos($name, ' ') == false)
- {
- $ValidateOK = 0;
- $strValidationMessage .= "\nName is Required!.<br />";
- }
- //Validating Message
- if(strpos($message, ' ') == false)
- {
- $ValidateOK = 0;
- $strValidationMessage .= "\nMessage is Required!.<br />";
- }
- //Function Of the Email Address
- function validate_email( $senderemail )
- { // this is a function; it receives info and returns a value.
- $email = trim( $senderemail ); # removes whitespace
- if(!empty($email) ):
- // validate email address syntax
- if( preg_match('/^[a-z0-9\_\.]+@[a-z0-9\-]+\.[a-z]+\.?[a-z]{1,4}$/i', $email, $match) ):
- return strtolower($match[0]); # valid!
- endif;
- endif;
- return false; # NOT valid!
- }// end function validate_email
- //Valadating Email Address
- $emailValidate = validate_email($email);
- if(!$emailValidate)
- {
- $boolValidateOK = 0;
- $strValidationMessage .= "\nEmail Address is Required.<br />";
- }
- // This will protect you from Security against email spams
- $badStrings = array("Content-Type:",
- "MIME-Version:",
- "Content-Transfer-Encoding:",
- "bcc:",
- "cc:");
- foreach($_POST as $k => $v){
- foreach($badStrings as $v2){
- if(strpos($v, $v2) !== false){
- // In case of spam, all actions taken here
- //header("HTTP/1.0 403 Forbidden");
- //exit; // stop all further PHP scripting, so mail will not be sent.
- $boolValidateOK = 0;
- $strValidationMessage = "There is a security problem with the formatting of this message. ";
- $strValidationMessage .= "Please try again.";
- }
- }
- }
- if($boolValidateOK == 1)
- {
- $strValidationMessage = "Email Has been Sent.";
- }
- }//End If
- ?>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
- <meta name="kewords" content="Rawad Merhi,Computer Service, Computer Business, RMCS,hardware,software installation,blue screen" />
- <link rel="stylesheet" type="text/css" href="assets/css/style.css">
- <link rel="shortcut icon" href="assets/images/favicon.ico">
- </head>
- </head>
- <body>
- <div class ="container">
- <header></header>
- <nav>
- <ul>
- <li><a href="contact.php">Contact</a></li>
- <li><a href="service.html">Services</a></li>
- <li><a href="index.html">Home</a></li>
- </ul>
- </nav>
- <div class="mainContent">
- <div class="form_Wrapper">
- <form name="contactform"id="contactform" method="post" action="contact.php">
- <p>
- <label for="name">Your Name:</label><br>
- <input type="text" name="name" id="name" value = "<?php echo $name?>"/>
- </p>
- <p>
- <label for="email">Your Email:</label><br>
- <input type="text" name="email" id="email" value = "<?php echo $email?>"/>
- </p>
- <p>
- <label for="message">Your Message:</label><br>
- <textarea name="message" name="message" id="message" value = "<?php echo $message?>"/></textarea>
- </p>
- <input type="submit" name="submit" value="Send Message" class="btn">
- <div id="formvalidate">
- <?php
- echo $strValidationMessage;
- ?>
- </div>
- </form>
- </div>
- </div><!--Close Main Content-->
- <footer>
- <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>
- <a href="https://twitter.com/Rawad_Merhi/"><img src="assets/images/twitter.png"class="icon"></a>
- <a href="https://www.facebook.com/RawadHomeComputerService"><img src="assets/images/facebook.png"class="icon"></a>
- <p>© Rawad Home Computer Service 2012</p>
- </footer>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement