| | |
Send form inputs to email address
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Apr 2007
Posts: 4
Reputation:
Solved Threads: 0
hi there, i have created a php website for my mobile DJ business, and want a booking enquiry form so people can fill out their details and email the data to us and we can then contact them about their booking.
I have created the form in html, and using an index.php file and the include code to load the html form in the page. you can view the file at:
http://voguefm.co.uk/xfaders/site/mo...e=Booking_Form
it is an inactive module at the moment.
basically i have experimented with using a sendmail.php file but i dont really have enough knowledge of php to get it to work properly.
I have created a script that sends me an email with the correct subject title but with no content in the main message of the email.
can anyone help me create a sendmail.php file that will send all of the data in the form? is it even possible? as it uses tick boxes and drop down menu's.
hopefully that can be understood by someone!
thanks for your help
I have created the form in html, and using an index.php file and the include code to load the html form in the page. you can view the file at:
http://voguefm.co.uk/xfaders/site/mo...e=Booking_Form
it is an inactive module at the moment.
basically i have experimented with using a sendmail.php file but i dont really have enough knowledge of php to get it to work properly.
I have created a script that sends me an email with the correct subject title but with no content in the main message of the email.
can anyone help me create a sendmail.php file that will send all of the data in the form? is it even possible? as it uses tick boxes and drop down menu's.
hopefully that can be understood by someone!
thanks for your help
Your php page that you use after the form is submitted would have to check all the check boxes to to see if they are checked:
Personally I would load all the form variables into variables to make things easier to manage and look at.
At this point you would create the actual mail script including all the info you need.
The basic setup to send mail is as follows:
mail(e-mail address to send to,subject,body,from)
Usualy this is put in an if statement just for error purposes if it does not work.
Here is an example contact us form that I have available for download on my site.
PHP Syntax (Toggle Plain Text)
if(isset($_POST['checkboxname'])) { $somevalue = "yes"; } else { $somevalue = "no"; }
Personally I would load all the form variables into variables to make things easier to manage and look at.
At this point you would create the actual mail script including all the info you need.
The basic setup to send mail is as follows:
mail(e-mail address to send to,subject,body,from)
Usualy this is put in an if statement just for error purposes if it does not work.
Here is an example contact us form that I have available for download on my site.
PHP Syntax (Toggle Plain Text)
<? //////////////////////////////////////////////////////// // // THIS CODE WAS CREATED BY ETYN.COM // YOU MAY USE THIS CODE FOR FREE // BUT THIS MESSAGE MUST STAY INTACT // /////////////////////////////////////////////////////// $formgood = true; $name = $_POST['name']; $email = $_POST['email']; $comments = $_POST['comments']; $to = "<a href="mailto:user@mail.com">user@mail.com</a>"; //Please change this to your e-mail address $message = "$name has submitted a contact form. \n\n $comments \n\n You can reply to $email"; //check to make sure all form elements were filled in if ($name == "") { echo 'You must provide your name to contact us. Please click the back, and try again'; $formgood = false; } if ($email == "") { echo 'We require an e-mail address in order for us to respond. Please go back and try again.'; $formgood = false; } if ($comments == "") { echo 'You must provide comments in order to submit this form. Please click back, and try again.'; $formgood = false; } if ($formgood) { if(mail($to, "A contact us form has been submitted by $name", $message, "From: $email\n")) { echo 'Thank you for submitting this form. We will review your comments and contact you shortly. <br><br> Copyright ' . date(Y) . ' ETYN Corps. All rights reserved.'; } else { echo "An error has occured. Please contact the webmaster."; } } else { echo "<br> Please review the comments above and try again."; echo '<br>Copyright ' . date(Y) . ' ETYN Corps. All rights reserved.'; } ?>
•
•
Join Date: Apr 2007
Posts: 4
Reputation:
Solved Threads: 0
that script works fine, thank you very much!
so if i wanted to add a field for a telephone number i would create the field in the html page. naming is 'telephone'
and in the PHP script it would look like this:
so if i wanted to add a field for a telephone number i would create the field in the html page. naming is 'telephone'
and in the PHP script it would look like this:
PHP Syntax (Toggle Plain Text)
<? //////////////////////////////////////////////////////// // $formgood = "t"; $telephone = $_POST['telephone']; $name = $_POST['name']; $email = $_POST['email']; $comments = $_POST['comments']; $to = "<a href="mailto:thex-faders@fsmail.net">thex-faders@fsmail.net</a>"; //Please change this to your e-mail address $message = "$name has submitted a contact form. \n\n $comments \n\n You can reply to $email"; //check to make sure all form elements were filled in if ($name == "") { echo 'You must provide your name to contact us. Please click the back, and try again'; $formgood = "f"; } if ($email == "") { echo 'We require an e-mail address in order for us to respond. Please go back and try again.'; $formgood = "f"; } if ($comments == "") { echo 'You must provide comments in order to submit this form. Please click back, and try again.'; $formgood = "f"; } if ($telephone == "") { echo 'You must provide comments in order to submit this form. Please click back, and try again.'; $formgood = "f"; } if ($formgood == "t") { if(mail($to, "A contact us form has been submitted by $name", $message, $telephone, "From: $email\n")) { echo 'Thank you for submitting this form. We will review your comments and contact you shortly. <br><br> Copyright ' . date(Y) . ' ETYN Corps. All rights reserved.'; } } else { echo '<br>Copyright ' . date(Y) . ' ETYN Corps. All rights reserved.'; } ?>
Not quite you don't place the telephone variable after the message variable you place it in the message variable. So the actual mail statement would not change. Your $message line at the beggining would change to something like this:
$message = "$name has submitted a contact form. \n\n $comments \n\n You can reply to $email \n Telephone: $telephone";
$message = "$name has submitted a contact form. \n\n $comments \n\n You can reply to $email \n Telephone: $telephone";
![]() |
Similar Threads
- setting up an automatic email reply from a form. (Site Layout and Usability)
- Res. Form/Dreamweaver 8/Email to Address (HTML and CSS)
- Using HTML tags in PHP code (PHP)
- creating the text file that a form sends to email (HTML and CSS)
- username=email address inputted on submission>is this possible (PHP)
- Form not sending email (PHP)
Other Threads in the PHP Forum
- Previous Thread: Parse Error Assitance Needed
- Next Thread: mysql injection
| Thread Tools | Search this Thread |
.htaccess alexa apache api array beginner beneath binary broadband broken cakephp checkbox class cms code convert cron curl database date display dynamic echo email emptydisplayvalue encode error fcc file files folder form forms function functions google howtowriteathesis href htaccess html image images include insert ip javascript joomla key keywords limit link login mail mail() memberships menu mlm multiple multipletables mysql mysql_real_escape_string network oop open passwords paypal pdf php provider query radio random redirect remote rss script search securephp server sessions smtp source space sql strip_tags syntax system table template tutorial update upload url user validator variable video voteup web youtube





