PDA

View Full Version : Submitting a form to email with php in dreamweaver


higgs2585
02-25-2011, 05:50 PM
Hi,


I am hoping someone can help me. I created a form in dreamweaver, about 20 different fields, including text and radio button options. I used the post method. I know the only way to get this sent to my email when the person hits submit is through PHP, which I know nothing about. I wrote up something and previewed it in the browser when i push sumbit it goes to my thank you page so to me it seems to work but as soon as I upload the files to the server and push submit nothing happens. Can some please help me in what I have to write in the php file and if I need to write anything in the html file? I've been looking through so many sites but can't seem to get anything to work. Thank you and any help is greatly appreciated!! I included the php code I have below. Thanks again

<?php
$msg="email sent from site\n";
$msg.="fname: $_POST[firstname]\n";
$msg.="lname: $_POST[lastname]\n";
$msg.="dob: $_POST[dob]\n";
$msg.="address: $_POST[address]\n";
$msg.="city: $_POST[city]\n";
$msg.="state: $_POST[state]\n";
$msg.="zip: $_POST[zip]\n";
$msg.="phone: $_POST[phone]\n";
$msg.="email2: $_POST[email2]\n";
$msg.="gender: $_POST[gender]\n";
$msg.="service: $_POST[service]\n";
$msg.="active-duty: $_POST[active_duty]\n";
$msg.="wartime_service: $_POST[wartime_service]\n";
$msg.="service_disability: $_POST[service_disability]\n";
$msg.="percent_injury: $_POST[percent_injury]\n";
$msg.="injury_description: $_POST[injury_description]\n";
$msg.="mi_assistance: $_POST[mi_assistance]\n";
$msg.="assistance_description: $_POST[assistance_description]\n";
$msg.="medals: $_POST[medals]\n";
$msg.="medals_list: $_POST[medals_list]\n";



$to ="email@yahoo.com";
$subject="HFODT Application";
$mailheaders="From HFODT Website\n";
mail($to, $subject, $msg, $mailheaders);

header("location: thank_you.html");
?>

edbr
02-25-2011, 11:37 PM
does the server have php on it?

higgs2585
02-26-2011, 06:22 AM
Yes the server has php

edbr
02-28-2011, 12:21 AM
try

$msg="email sent from site". "\n\n";
$msg.="fname:". $_POST['firstname']. "\n\n";
$msg.="lname:". $_POST['lastname']. "\n\n";


etc

higgs2585
03-01-2011, 09:26 PM
That code worked. But I still do not get the email with all the information entered. Am I missing something for that? Do I need another php function?
Thanks again for all your help

edbr
03-01-2011, 11:48 PM
post the code you have now

higgs2585
03-02-2011, 12:39 AM
<?php
if(isset($_POST['submit'])) {

$msg="email sent from site". "\n\n";
$msg.="fname:". $_POST['firstname']. "\n\n";
$msg.="lname:". $_POST['lastname']. "\n\n";
$msg.="dob:". $_POST['dob']. "\n\n";
$msg.="address:". $_POST['address']. "\n\n";
$msg.="city:". $_POST['city']. "\n\n";
$msg.="state:". $_POST['state']. "\n\n";
$msg.="zip:". $_POST['zip']. "\n\n";
$msg.="phone:". $_POST['phone']. "\n\n";
$msg.="email2:". $_POST['email2']. "\n\n";
$msg.="gender:". $_POST['gender']. "\n\n";
$msg.="service:". $_POST['service']. "\n\n";
$msg.="active-duty:". $_POST['active_duty']. "\n\n";
$msg.="wartime_service:". $_POST['wartime_service']. "\n\n";
$msg.="service_disability:". $_POST['service_disability']. "\n\n";
$msg.="percent_injury:". $_POST['percent_injury']. "\n\n";
$msg.="injury_description:". $_POST['injury_description']. "\n\n";
$msg.="mi_assistance:". $_POST['mi_assistance']. "\n\n";
$msg.="assistance_description:". $_POST['assistance_description']. "\n\n";
$msg.="medals:". $_POST['medals']. "\n\n";
$msg.="medals_list:". $_POST['medals_list']. "\n\n";




$to ="email@yahoo.com";
$subject="HFODT Application";
$mailheaders="From HFODT Website\n";
mail($to, $subject, $msg, $mailheaders);

header("location: thank_you.html");
}
?>