Jump to content


Auto responder


5 replies to this topic

#1 Hooch

    Young Padawan

  • Members
  • Pip
  • 158 posts
  • Location:Brockville, Ontario

Posted 15 March 2006 - 11:57 AM

Hello all.
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.


#2 Hooch

    Young Padawan

  • Members
  • Pip
  • 158 posts
  • Location:Brockville, Ontario

Posted 15 March 2006 - 02:47 PM

Problem fixed.

I forgot a semi-colon after the $replymessage.

#3 MillerTime

    Young Padawan

  • Members
  • Pip
  • 69 posts

Posted 15 March 2006 - 11:16 PM

i know you finished this but i was just reading through your code there and it seems as though if your accessing contact.php directly, you get a redirection but then when a person does not fill in all the fields, you send them directly to contact.php..wouldnt that give them an error?

#4 Hooch

    Young Padawan

  • Members
  • Pip
  • 158 posts
  • Location:Brockville, Ontario

Posted 16 March 2006 - 09:43 AM

Hey Millertime.
The file itself is called contact.php..so it's just going back to itself.
That works fine. But the problem is all the fields are empty when you go back.

This is not my code..I found it on the net a few months back. I always keep the authors info, but this one
doesn't have any ;)
I am no coder..I just learn what I need to. I can cut and paste with the best of them.
This is an awsome contact form (for my needs) I just need to find out how to keep the existing info to
stay if the user doesn't fill out the all the fields.

Any solutions?? Anyone??

Thank you..Hooch
PS that's one awsome upload script you have Miller. :) :D

#5 MillerTime

    Young Padawan

  • Members
  • Pip
  • 69 posts

Posted 17 March 2006 - 01:51 AM

hmm..you can trying using $_GET..but that would leave one heck of an url

#6 coolaid

    P2L Jedi Master

  • Members
  • PipPipPipPip
  • 1,435 posts
  • Gender:Male
  • Interests:i wonder..

Posted 17 March 2006 - 03:25 AM

the obvious way is to use an if else statement....

<?
if(isset($submit)){
   if(strlen($var) <= "0"){
?>
<html>
full webpage..... WITH error message and using value="<? echo $_POST['var']; ?>" in the input fields...
</html>
<?
   }
   else{
	// proccesssing data
   }
}
else{
// echo form data
}
?>

i'd try to implement it into the script your using but thats one hell of a long script.. im not about to tweak it

Edited by coolaid, 17 March 2006 - 03:25 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users