sonehs Posted July 27, 2009 Share Posted July 27, 2009 Look at www.tritusco.com/contactus.html The code below is supposed to help me submit the form into a email. I'd also like help figuring out just how I would make it so the subject of the email is which ever box is checked. Thx for the help <?php // Check for form submission: if(isset($_POST['submitted'])) { // Minimal form validation: if(!empty($_POST['name'])&& !empty($_POST['email']) && !empty($_POST['phone']) && !empty($_POST['message'])) { // Create the body: $body = "Name:$_POST['name']}\nPhone:$_POST['phone']}\n\nMessage:$_POST['message']}"; // Make it no longer then 70 characters long: $body = wordwrap($body, 70); // Send the email mail('[email protected]', 'Contact Form Submission', $body, "From: {$_POST['email']}"); // Print a message: echo '<p><em>Thank you for contacting us. We will get back to you soon.</em></p>'; // Clear $_POST (so that forms not sticky): $_POST = array() } else { echo '<p style="font-weight: bold; color: #C00">Please fill out the form completely.</p>'; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/167616-i-need-help-with-form-submit-by-emailthx/ Share on other sites More sharing options...
abazoskib Posted July 27, 2009 Share Posted July 27, 2009 switch($checkboxValue) { case 1: $subject="Hello there!"; break; case 2: and so on... mail('[email protected]', $subject, $body, "From: {$_POST['email']}"); Quote Link to comment https://forums.phpfreaks.com/topic/167616-i-need-help-with-form-submit-by-emailthx/#findComment-883900 Share on other sites More sharing options...
sonehs Posted July 28, 2009 Author Share Posted July 28, 2009 switch($checkboxValue) { case 1: $subject="Hello there!"; break; case 2: and so on... mail('[email protected]', $subject, $body, "From: {$_POST['email']}"); Quote Link to comment https://forums.phpfreaks.com/topic/167616-i-need-help-with-form-submit-by-emailthx/#findComment-885385 Share on other sites More sharing options...
.josh Posted July 28, 2009 Share Posted July 28, 2009 Well I don't see any form so I can't verify, but I assume by checkbox you mean radio buttons? Why not just put the subject as the radio button value and just do $subject = $_POST['subject']; // or whatever the radio button is named Quote Link to comment https://forums.phpfreaks.com/topic/167616-i-need-help-with-form-submit-by-emailthx/#findComment-885392 Share on other sites More sharing options...
ldougherty Posted July 28, 2009 Share Posted July 28, 2009 I see your form on http://www.tritusco.com/contactus.html and the radio buttons for Services Partnership Media Join Team There is however no information on your form processing to grab the information for these fields. We'd need to know what the name of these radio buttons are so you can grab the variables as $_POST[var] to use it in the email submission. The best bet is for you to post up the code for your form itself. Quote Link to comment https://forums.phpfreaks.com/topic/167616-i-need-help-with-form-submit-by-emailthx/#findComment-885432 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.