I am making a contact form
Everything works except the autoresponder (at bottom of code) to the person who fills the form out.
The email gets sent...but no message appears.
Could someone please have a look at the script?
Thank you
<?
// keep people from accessing this page directly
if (eregi('contact.php', $_SERVER['PHP_SELF'])) {
// go to index page
header('Location: ../index.html');
die();
}
?>
<?php
echo "* Denotes required fields. <br />";
// put your email here
$send_to = "me@mysite";
// This is what is displayed in the email subject line
$subject = "Message from mysite.com";
// This is displayed if all the fields are not filled in
$empty_fields_message = "<p>Please <a href='contact.php'>go back</a> and complete all the fields in the form!</p>";
// This is displayed when the email has been sent
$thankyou_message = "<p>Thank you. Your message has been sent! =)<br /><br /><a href='../index.html'><< Back to Main</a></p>";
// set up info
$nowDay=date("m.d.Y");
$nowClock=date("H:i:s");
$http_referrer = getenv( "HTTP_REFERER" );
// You do not need to edit below this line
$name = stripslashes($_POST['txtName']);
$email = stripslashes($_POST['txtEmail']);
$phone = stripslashes($_POST['txtPhone']);
$message = stripslashes($_POST['txtMessage']);
if (!isset($_POST['txtName'])) {
?>
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>" id="mailme" name="mailme">
<b>Name:</b> <span class="error"> *</span>
<input name="txtName" type="text" title="Enter your name" size="35" maxlength="35"/>
<br /> <b>Email:</b> <span class="error"> *</span>
<input name="txtEmail" type="text" title="Enter your email address" size="35" maxlength="35"/>
<br /><b>Phone:</b>
<input name="txtPhone" type="text" title="Enter your phone number" size="15" maxlength="15"/>
Extension: <input name="txtExt" type="text" title="Enter your extension" size="5" maxlength="5"/>
<br /><b>Contact?</b>
<input name="contact" type="radio" value="yes" checked>
Yes
<input name="contact" type="radio" value="no">
No
<br /><b>How did you find us?<br /></b>
<input name="found" type="radio" value="advertisement">Advertisement <br />
<input name="found" type="radio" value="word of mouth">Word of Mouth <br />
<input name="found" type="radio" value="search_engine">Search Engine <br />
<input name="found" type="radio" value="web_link">Web Link <br />
<input name="found" type="radio" value="other" checked>Other<br />
<b>Message:</b> <span class="error"> *</span> <br />
<textarea name="txtMessage" cols="50" rows="10" wrap="VIRTUAL" /></textarea>
<br />
<input name="Reset" type="reset" value="Clear"/>
<input name="submit" type="submit" value="Send"/>
<br />
</form>
<?php
}
elseif (empty($name) || empty($email) || empty($message)) {
echo @$empty_fields_message;
}
else {
// Stop the form being used from an external URL
// Get the referring URL
@$referer = $_SERVER['HTTP_REFERER'];
// Get the URL of this page
@$this_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"];
// If the referring URL and the URL of this page don't match then
// display a message and don't send the email.
if ($referer != $this_url) {
echo "You do not have permission to use this script from another URL.";
exit;
}
@$messageproper =
// we now generate a nice form for emailing
"Message recieved: $nowDay at $nowClock:\n\n" .
"Email Sent From: $http_referrer\n\n" .
"Name: $name\n\n".
"Email: $email\n\n".
"Phone Number: $phone\n\n".
"Contact?: $contact\n\n".
"Found site By: $found\n\n".
"------------------------ COMMENTS ------------------------\n\n\n" .
$message .
"\n\n\n-----------------------------------------------------------------\n";
// The URLs matched so send the email
mail($send_to, $subject, $messageproper, "From: $name <$email>");
# Autoresponder #############################################################
// note , the . (dot) joins two strings. to end a string, use semi-colon;
$replysubject =
"Query from mysite.com"; // send our subject header
$replymessage =
"Dear " .
$name .
"Thank you for your email. \nIf you had so requested, we will get back to you as soon as possible. " .
"\n\nRegards," .
"\n mysite.com" .
mail( "$email", "$replysubject", "$replymessage", "From:$send_to" );
// Display the thankyou message
echo $thankyou_message;
}
?>
Thank you..Hooch
Edited by Hooch, 15 March 2006 - 11:58 AM.
