View Full Version : PHP email form script

06-26-2008, 10:18 AM
This one is going to bread and butter stuff to you experts out there!!

I'm trying to implement a email contact form on a website. I've done it before but this time i thought i would write the .php file, a nice easy thing to learn with!!

so far i've managed to get the majority of it working, i submit the form and i recieve an email at the appropriate email address. However, i'm struggling to actually get the info that is posted from the form i.e. name, company, tel no. etc. into the email.

Here is the code I have...

$Name = $_POST['Name'] ;
$Company = $_POST['Company'] ;
$TelNo = $_POST['TelNo'] ;
$Email = $_POST['Email'] ;
$Enquiry = $_POST['Enquiry'] ;

mail( "james@********.net", "Enquiry From BPS Website", "From: $Email", );

header( "Location: http://www.*********.net/BPS/thankyou.html" );


I appreciate that in the above i haven't actually incorporated the content of the variables declared. However, i spent last night shifting them around in all sorts of variations / locations and recieved various error messages when testing! so i've stripped it back to something that works!!

Would someone be kind enought to point me in the right direction on how i add the content of the variable into the email - i've never coded PHP before so please bare with me!!

if you need to see the form its here www.virtualform.net/BPS/contact_us.html (http://www.virtualform.net/BPS/contact_us.html)

06-26-2008, 10:22 AM
your form method is set to GET but your using POST to catch the form data

06-26-2008, 10:42 AM
Well i guess that is a basic error that won't help! I'm sure i changed it to POST, somehow must have changed it back!

just been doing a little more reading and i'm thinking that i also need to have $message element in the script that i then add the variables to????

Thanks for the quick feed back David!