. The same goes for check boxes if you are using more than one with the same name, like so: AppleOrangeBanana This is a PHP script. In order for it to run, you must have PHP (version 4.1.0 or later) on your webhosting account, and have the PHP mail() function enabled. If you are not sure about this, please ask your webhost about it. SETUP INSTRUCTIONS Step 1: Put the form on your webpage Step 2: Enter your email address and continue link below Step 3: Upload the files to your webspace Step 1: To put the form on your webpage, copy the code below as it is, and paste it into your webpage:
Step 2: Enter your email address. Enter the email address below to send the contents of the form to. You can enter more than one email address separated by commas, like so: $my_email = "bob@example.com,sales@example.co.uk,jane@example.com"; */ $my_email = "realestatebarbour@ripnet.com,inquiries@vinesmart.com"; /* Enter the continue link to offer the user after the form is sent. If you do not change this, your visitor will be given a continue link to your homepage. If you do change it, remove the "/" symbol below and replace with the name of the page to link to, eg: "mypage.htm" or "http://www.elsewhere.com/page.htm" */ $continue = "/"; /* Step 3: Save this file (FormToEmail.php) and upload it together with your webpage to your webspace. IMPORTANT - The file name is case sensitive! You must save it exactly as it is named above! Do not put this script in your cgi-bin directory (folder) it may not work from there. THAT'S IT, FINISHED! You do not need to make any changes below this line. */ // Initialise variables $errors = array(); if($_SERVER['REQUEST_METHOD'] == "POST"){$form_input = $_POST;}elseif($_SERVER['REQUEST_METHOD'] == "GET"){$form_input = $_GET;}else{exit;} // Remove leading whitespace from all values. function recursive_array_check(&$element_value) { if(!is_array($element_value)){$element_value = ltrim($element_value);} else { foreach($element_value as $key => $value){$element_value[$key] = recursive_array_check($value);} } return $element_value; } recursive_array_check($form_input); // Check referrer is from same site. if(!(isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST']))){$errors[] = "You must enable referrer logging to use the form";} // Check for a blank form. function recursive_array_check_blank($element_value) { global $set; if(!is_array($element_value)){if(!empty($element_value)){$set = 1;}} else { foreach($element_value as $value){if($set){break;} recursive_array_check_blank($value);} } } recursive_array_check_blank($form_input); if(!$set){$errors[] = "You cannot send a blank form";} // Strip HTML tags from all fields. function recursive_array_check2(&$element_value) { if(!is_array($element_value)){$element_value = strip_tags($element_value);} else { foreach($element_value as $key => $value){$element_value[$key] = recursive_array_check2($value);} } return $element_value; } recursive_array_check2($form_input); // Validate name field. if(isset($form_input['name']) && !empty($form_input['name'])) { if(preg_match("`[\r\n]`",$form_input['name'])){$errors[] = "You have submitted an invalid new line character";} if(preg_match("/[^a-z' -]/i",stripslashes($form_input['name']))){$errors[] = "You have submitted an invalid character in the name field";} } // Validate email field. if(isset($form_input['email']) && !empty($form_input['email'])) { if(preg_match("`[\r\n]`",$form_input['email'])){$errors[] = "You have submitted an invalid new line character";} if(!preg_match('/^([a-z][a-z0-9_.-\/\%]*@[^\s\"\)\?<>]+\.[a-z]{2,6})$/i',$form_input['email'])){$errors[] = "Email address is invalid";} } // Display any errors and exit if errors exist. if(count($errors)){foreach($errors as $value){print "$value
|
|
||||||||||||||||
|
|
|||||||||||||||||
Copyright © 2009 VineSmart.com All Rights Reserved.
|
|||||||||||||||||