Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP form auto response
    text
    copied!<p>I am using the following php code which has been given to me, it works fine, apart from the auto response bit. I know its not a lot of code I just don't know how to do it or why it's not working.</p> <p>Any help would be appreciated. Thanks in advance.</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt; &lt;title&gt; - Contact Us&lt;/title&gt; &lt;!-- css --&gt; &lt;link rel="stylesheet" type="text/css" href="css/reset.css" /&gt; &lt;link rel="stylesheet" type="text/css" href="css/styles.css" /&gt; &lt;link rel="stylesheet" type="text/css" href="css/colorbox.css" /&gt; &lt;!-- javascript libraries --&gt; &lt;?php require_once('includes/js.php'); ?&gt; &lt;/head&gt; &lt;body&gt; &lt;?php //FIll out the settings below before using this script $your_email = "(email address)"; $website = "(website name)"; //BOTS TO BLOCK $bots = "/(Indy|Blaiz|Java|libwww-perl|Python|OutfoxBot|User-Agent|PycURL|AlphaServer|T8Abot|Syntryx|WinHttp|WebBandit|nicebot)/i"; //Check if known bot is visiting if (preg_match($bots, $_SERVER["HTTP_USER_AGENT"])) { exit ("Sorry bots are not allowed here!"); } //Known Exploits $exploits = "/(content-type|bcc:|cc:|from:|reply-to:|javascript|onclick|onload)/i"; //Spam words $spam_words = "/(viagra|poker|blackjack|porn|sex)/i"; // BAD WORDS $words = "/( bitch|dick|pussy|pussies|ass|fuck|cum|cumshot|cum shot| gangbang|gang bang|god dammit|goddammit|viagra|anus|analsex )/i"; //BAD WORD/SPAM WORD/EXPLOIT BLOCKER function wordBlock($word) { //Make variables global global $words; global $exploits; global $spam_words; if (preg_match($words, $word)) { $word = preg_replace($words, "#####", $word); } if(preg_match($exploits,$word)){ $word = preg_replace($exploits,"",$word); } if(preg_match($spam_words,$word)){ $word = preg_replace($spam_words,"$$$$",$word); } return $word; } //CLean data function function dataClean($data) { $data = stripslashes(trim(rawurldecode(strip_tags($data)))); return $data; } //CREATE MAIN VARIABLES $name = (isset ($_POST['name'])) ? dataClean($_POST['name']) : FALSE; $company = (isset ($_POST['company'])) ? dataClean($_POST['company']) : FALSE; $address = (isset ($_POST['address'])) ? dataClean($_POST['address']) : FALSE; $postcode = (isset ($_POST['postcode'])) ? dataClean($_POST['postcode']) : FALSE; $phone = (isset ($_POST['phone'])) ? dataClean($_POST['phone']) : FALSE; $email = (isset ($_POST['email'])) ? dataClean($_POST['email']) : FALSE; $comment = (isset ($_POST['message'])) ? wordBlock(dataClean($_POST['message'])) : FALSE; $submit = (isset ($_POST['send'])) ? TRUE : FALSE; $email_check = "/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$/i"; //$ip = $_SERVER["REMOTE_ADDR"]; $errors = array(); //Check if send button was clicked if ($submit) { if (!$name) { $errors[] = "Please enter a name!"; } if ($name) { if (!ereg("^[A-Za-z' -]*$", $name)) { $errors[] = "You may not use special characters in the name field!"; } } if (!$email) { $errors[] = "Please enter an email address!"; } if ($email) { if (!preg_match($email_check, $email)) { $errors[] = "The E-mail you entered is invalid!"; } } /* if (!$subject) { $errors[] = "Please enter an email subject!"; } */ if (!$comment) { $errors[] = "Please don't leave the message field blank!"; } //Check if any errors are present if (count($errors) &gt; 0) { foreach ($errors AS $error) { print "&amp;bull; $error &lt;br /&gt;"; } } else { //MESSAGE TO SEND TO ADMIN //Create main headers $headers = "From: " . $website . " &lt;$your_email&gt; \n"; $headers .= "Reply-to:" . $email . " \n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Transfer-Encoding: 8bit\n"; $headers .= "Content-Type: text/html; charset=UTF-8\n"; $message = ""; $message .= "&lt;h1&gt;New E-Mail From " . $website . "&lt;/h1&gt;&lt;br /&gt;&lt;br /&gt;"; $message .= "&lt;b&gt;Name:&lt;/b&gt; " . $name . "&lt;br /&gt;"; $message .= "&lt;b&gt;Company:&lt;/b&gt; " . $company . "&lt;br /&gt;"; $message .= "&lt;b&gt;Address:&lt;/b&gt; " . $address . "&lt;br /&gt;"; $message .= "&lt;b&gt;Postcode:&lt;/b &gt; " . $postcode . "&lt;br /&gt;"; $message .= "&lt;b&gt;Phone No:&lt;/b&gt; " . $phone . "&lt;br /&gt;"; $message .= "&lt;b&gt;E-mail:&lt;/b&gt; " . $email . "&lt;br /&gt;"; $message .= "&lt;b&gt;Message:&lt;/b&gt; " . $comment . "&lt;br /&gt;"; //E-mails subject $mail_subject = "Message from " . $website . ""; /* CHECK TO BE SURE FIRST E-MAIL TO ADMIN IS A SUCCESS AND SEND EMAIL TO ADMIN OTHERWISE DON'T SEND AUTO RESPONCE */ if (mail($your_email, $mail_subject, $message, $headers)) { //UNSET ALL VARIABLES unset ($name, $email, $company, $address, $postcode, $phone, $comment, $_REQUEST); //JAVASCRIPT SUCCESS MESSAGE echo " &lt;script type='text/javascript' language='JavaScript'&gt; alert('Your message has been sent'); &lt;/script&gt; "; //SUCCESS MESSAGE TO SHOW IF JAVASCRIPT IS DISABLED echo "&lt;noscript&gt;&lt;p&gt;THANK YOU YOUR MESSAGE HAS BEEN SENT&lt;/p&gt;&lt;/noscript&gt;"; /* -----------------END MAIL BLOCK FOR SENDING TO ADMIN AND START AUTO RESPONCE SEND----------------- */ //AUTO RESPONCE MESSAGE //Create main headers $headers = "From: " . $website . " &lt;$your_email&gt; \n"; $headers .= "Reply-to:" . $your_email . " \n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Transfer-Encoding: 8bit\n"; $headers .= "Content-Type: text/html; charset=UTF-8\n"; $message = ""; $message .= "&lt;h1&gt;Thank You For Contacting Us &lt;/h1&gt;&lt;br /&gt;&lt;br /&gt;"; $message .= "On behalf of &lt;b&gt;" . $website . "&lt;/b&gt; we wanna thank you for contacting us and to let you know we will respond to your message as soon as possible thank you again."; //E-mails subject $mail_subject = "Thank you for contacting " . $website . ""; //Send the email mail($email, $mail_subject, $message, $headers); /* -----------------END MAIL BLOCK FOR SENDING AUTO RESPONCE ----------------- */ } else { echo " &lt;script type='text/javascript' language='JavaScript'&gt; alert('Sorry could not send your message'); &lt;/script&gt; "; echo "&lt;noscript&gt;&lt;p style='color:red;'&gt;SORRY COULD NOT SEND YOUR MESSAGE&lt;/p&gt;&lt;/noscript&gt;"; } } } ?&gt; &lt;div id="wrapper"&gt; &lt;div id="grad_overlay"&gt; &lt;!-- Header --&gt; &lt;div id="header"&gt; &lt;a href="index.php" title="Regal Balustrades"&gt;&lt;img src="images/regal_logo.png" alt="Regal Balustrades" /&gt;&lt;/a&gt; &lt;div id="strapline"&gt; &lt;img src="images/strapline.png" alt="Architectural metalwork systems" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- Navigation --&gt; &lt;div id="nav"&gt; &lt;?php require_once('includes/nav.php'); ?&gt; &lt;/div&gt; &lt;!-- Content --&gt; &lt;div id="content"&gt; &lt;div id="details"&gt; &lt;p class="getintouch env"&gt;Get In Touch&lt;/p&gt; &lt;ul class="details"&gt; &lt;li&gt;T. (0117) 935 3888&lt;/li&gt; &lt;li&gt;F. (0117) 967 7333&lt;/li&gt; &lt;li&gt;E. &lt;a href="mailto:sales@regalbalustrades.co.uk" title="Contact via email"&gt;sales@regalbalustrades.co.uk&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;p class="whereto hse"&gt;Where To Find Us&lt;/p&gt; &lt;ul class="details"&gt; &lt;li&gt;Regal Balustrades&lt;/li&gt; &lt;li&gt;Regal House, &lt;/li&gt; &lt;li&gt;Honey Hill Road,&lt;/li&gt; &lt;li&gt;Kingswood, &lt;/li&gt; &lt;li&gt;Bristol BS15 4HG&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div id="contact"&gt; &lt;h1&gt;Contact us&lt;/h1&gt; &lt;p&gt;Please use this form to request further information about Regal Balustrades and our services. To speak to a member of our staff in person, please call us on 0117 9353888&lt;/p&gt; &lt;div id="form"&gt; &lt;form method='POST' action='&lt;?php echo "".$_SERVER['PHP_SELF'].""; ?&gt;'&gt; &lt;p class='form-element'&gt; &lt;label for='name'&gt;Name:&lt;/label&gt; &lt;input type='text' name='name' value='&lt;?php echo "" . $_REQUEST['name'] . "";?&gt;' /&gt; &lt;/p&gt; &lt;p class='form-element'&gt; &lt;label for='company'&gt;Company:&lt;/label&gt; &lt;input type='text' name='company' value='&lt;?php echo "" . $_REQUEST['company'] . "";?&gt;' /&gt; &lt;/p&gt; &lt;p class='form-element'&gt; &lt;label for='address'&gt;Address:&lt;/label&gt; &lt;textarea name='address' rows='5' id='address' class='address' &gt;&lt;?php echo "" . $_REQUEST['address'] . "";?&gt;&lt;/textarea&gt; &lt;/p&gt; &lt;p class='form-element'&gt; &lt;label for='postcode'&gt;Postcode:&lt;/label&gt; &lt;input type='text' name='postcode' value='&lt;?php echo "" . $_REQUEST['postcode'] . "";?&gt;' /&gt; &lt;/p&gt; &lt;p class='form-element'&gt; &lt;label for='phone'&gt;Telephone:&lt;/label&gt; &lt;input type='text' name='phone' value='&lt;?php echo "" . $_REQUEST['phone'] . "";?&gt;' /&gt; &lt;/p&gt; &lt;p class='form-element'&gt; &lt;label for='email'&gt;Email:&lt;/label&gt; &lt;input type='text' name='email' value='&lt;?php echo "" . $_REQUEST['email'] . "";?&gt;' /&gt; &lt;/p&gt; &lt;/div&gt; &lt;div id='form-right'&gt; &lt;p class='form-element'&gt; &lt;label for='message'&gt;Enquiry:&lt;/label&gt; &lt;textarea name='message' class='enquiry' id='enquiry' rows='5' cols='40' &gt;&lt;?php echo "" . $_REQUEST['message'] . "";?&gt;&lt;/textarea&gt; &lt;/p&gt; &lt;p class='form-element'&gt; &lt;input type='submit' class='submit' name='send' value='Send message' /&gt; &lt;/p&gt; &lt;/div&gt; &lt;p class='nb'&gt;&lt;em&gt;We will respond as soon as possible.&lt;/em&gt;&lt;/p&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- Footer --&gt; &lt;div id="footer-container"&gt; &lt;?php require_once('includes/footer.php'); ?&gt; &lt;/div&gt; &lt;!-- js functions --&gt; &lt;script&gt; $(document).ready(function() { $("ul#navig li:nth-child(6)").addClass("navon"); }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload