Im trying to created a a simple form to email, having use it on my contact page it works fine, however I’m trying to modify it into a simple booking form with extra fields including telephone, check in/out dates etc. Its on this site:
However, Ive added extra vaiable e.g. “$checkin” and the form sends fine, although now the sender’s email address changes to paultoner@dagger.dreamhost.com (my host) instead of the email entered by the person using the form. I have pasted the code below, I would be REALLY grateful if someone could help. Many Thanks Paul
PHP:
[COLOR=“Red”]
<?
//Configuration
$email_address = “paultoner2005@hotmail.com”; //This should be changed to your email address.
$subject_prefix = "Shalom House Booking Request | "; //This will be the subject prefix of all emails. default "Website Contact - User Subject
// — Do not modify below —
//Collects varibles from previous page.
//This part should prevent malicous doings.
//Most servers are setup in such a way that this section is not needed but its a good security precaution to have.
$from = urldecode($email);
if (eregi(“\r”,$from) || eregi("
",$from)){
print “Malformed Headers were detected.”;
exit;
}
//This part sends the email to you.
mail($email_address, $subject, $telephone, $checkin, “From: $name <$email>
X-Mailer: Simple PHP Contact Form 1.0 (www.korske.com)”);
//Redirects to sent.htm
header(“Location: booking_received.html”)
Or dont, since $email is transformed into $from halfway through the script, and $email_address is set in the very first line to be the delivery address, not a form field.
Well, it really depends on what sort of learner you are, and what programming experience you have.
For example, look at the mail() documentation page. Does this make sense to you? Or do you look at the top box and go ‘uh… technical jargon. huh?’.
Compare your initial post, my fix, and that mail documentation, and see if you can follow where your error occurred and why (both why you had the error, and how/why the fix works).
Thank you for the help, especially Star Lion, much appreciated. I’m really struglling with PHP. Does anyone know of any good online resources to quickly learn the basics, as I know how to build a form and site easily with CSS but as I downloaded the php form I’m just doing guesswork.
I can see how the forms work to a certain degree but fixing errors/modification is my weakness.
you can append the email address by ‘<’.$email_address.‘>’
I think this is ur problem…
otherwise send the error message u got…for better clarification…
Thanks for the help, I do have a good base of XHTML and CSS. I find it easy to hand code, but with PHP etc im bluffing my way through it. I can see how the mail works, it collects the variables set at the begining of the script and used from the “labels” in the form. But I know at the minitue I wouldnt be able to write a contact form from scratch.
I will go throught the W3C tutorials, I have briefly looked at them before. Do you know how I could add CAPTHA to the form? Do people write this code themselves or dot hey simply copy and paste to protect from Spam?