Hi, 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 dont know how to do it or why it snot working.
Any help would be appreciated. thanks in advance.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title> - Contact Us</title>
<!-- css -->
<link rel="stylesheet" type="text/css" href="css/reset.css" />
<link rel="stylesheet" type="text/css" href="css/styles.css" />
<link rel="stylesheet" type="text/css" href="css/colorbox.css" />
<!-- javascript libraries -->
<?php require_once('includes/js.php'); ?>
</head>
<body>
<?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) > 0) {
foreach ($errors AS $error) {
print "• $error <br />";
}
}
else {
//MESSAGE TO SEND TO ADMIN
//Create main
headers
$headers = "From: " . $website . " <$your_email> \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 .= "<h1>New E-Mail From " . $website . "</h1><br /><br />";
$message .= "<b>Name:</b> " . $name . "<br />";
$message .= "<b>Company:</b> " . $company . "<br />";
$message .= "<b>Address:</b> " . $address . "<br />";
$message .= "<b>Postcode:</b > " . $postcode . "<br />";
$message .= "<b>Phone No:</b> " . $phone . "<br />";
$message .= "<b>E-mail:</b> " . $email . "<br />";
$message .= "<b>Message:</b> " . $comment . "<br />";
//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 "
<script type='text/javascript' language='JavaScript'>
alert('Your message has been sent');
</script>
";
//SUCCESS MESSAGE TO SHOW IF JAVASCRIPT IS DISABLED
echo "<noscript><p>THANK YOU YOUR MESSAGE HAS BEEN SENT</p></noscript>";
/*
-----------------END MAIL BLOCK FOR SENDING TO ADMIN AND START AUTO RESPONCE SEND-----------------
*/
//AUTO RESPONCE MESSAGE
//Create main
headers
$headers = "From: " . $website . " <$your_email> \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 .= "<h1>Thank You For Contacting Us </h1><br /><br />";
$message .= "On behalf of <b>" . $website . "</b> 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 "
<script type='text/javascript' language='JavaScript'>
alert('Sorry could not send your message');
</script>
";
echo "<noscript><p style='color:red;'>SORRY COULD NOT SEND YOUR MESSAGE</p></noscript>";
}
}
}
?>
<div id="wrapper">
<div id="grad_overlay">
<!-- Header -->
<div id="header">
<a href="index.php" title="Regal Balustrades"><img src="images/regal_logo.png" alt="Regal Balustrades" /></a>
<div id="strapline">
<img src="images/strapline.png" alt="Architectural metalwork systems" />
</div>
</div>
<!-- Navigation -->
<div id="nav">
<?php require_once('includes/nav.php'); ?>
</div>
<!-- Content -->
<div id="content">
<div id="details">
<p class="getintouch env">Get In Touch</p>
<ul class="details">
<li>T. (0117) 935 3888</li>
<li>F. (0117) 967 7333</li>
<li>E. <a href="mailto:
[email protected]" title="Contact via
email">
[email protected]</a></li>
</ul>
<p class="whereto hse">Where To Find Us</p>
<ul class="details">
<li>Regal Balustrades</li>
<li>Regal House, </li>
<li>Honey Hill Road,</li>
<li>Kingswood, </li>
<li>Bristol BS15 4HG</li>
</ul>
</div>
<div id="contact">
<h1>Contact us</h1>
<p>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</p>
<div id="form">
<form method='POST' action='<?php echo "".$_SERVER['PHP_SELF'].""; ?>'>
<p class='form-element'>
<label for='name'>Name:</label>
<input type='text' name='name' value='<?php echo "" . $_REQUEST['name'] . "";?>' />
</p>
<p class='form-element'>
<label for='company'>Company:</label>
<input type='text' name='company' value='<?php echo "" . $_REQUEST['company'] . "";?>' />
</p>
<p class='form-element'>
<label for='address'>Address:</label>
<textarea name='address' rows='5' id='address' class='address' ><?php echo "" . $_REQUEST['address'] . "";?></textarea>
</p>
<p class='form-element'>
<label for='postcode'>Postcode:</label>
<input type='text' name='postcode' value='<?php echo "" . $_REQUEST['postcode'] . "";?>' />
</p>
<p class='form-element'>
<label for='phone'>Telephone:</label>
<input type='text' name='phone' value='<?php echo "" . $_REQUEST['phone'] . "";?>' />
</p>
<p class='form-element'>
<label for='
email'>Email:</label>
<input type='text' name='
email' value='<?php echo "" . $_REQUEST['
email'] . "";?>' />
</p>
</div>
<div id='form-right'>
<p class='form-element'>
<label for='message'>Enquiry:</label>
<textarea name='message' class='enquiry' id='enquiry' rows='5' cols='40' ><?php echo "" . $_REQUEST['message'] . "";?></textarea>
</p>
<p class='form-element'>
<input type='submit' class='submit' name='send' value='Send message' />
</p>
</div>
<p class='nb'><em>We will respond as soon as possible.</em></p>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- Footer -->
<div id="footer-container">
<?php require_once('includes/footer.php'); ?>
</div>
<!-- js functions -->
<script>
$(document).ready(function() {
$("ul#navig li:nth-child(6)").addClass("navon");
});
</script>
</body>
</html>