goldie Posted July 23, 2013 Share Posted July 23, 2013 This is going to seem so easy for all of you. I have created a simple form at: http://medicallakeveterinaryclinic.com/schedule.html. There are two groups in the form: (1) dog, cat, other and (2) email, call. The form sends the info by email just fine until I ask it to print anything from these 2 groups. I do not know PHP well enough to get it to print the one item from each group that was clicked on by the user. Here is the code. It is the "mail" line at the end that I am doing wrong. __________________ <?php/*This first bit sets the email address that you want the form to be submitted to.You will need to change this value to a valid email address that you can access.*/$webmaster_email = "jeannette@medicallakevetclinic.com";/*This bit sets the URLs of the supporting pages.If you change the names of any of the pages, you will need to change the values here.*/$feedback_page = "schedule.html";$error_page = "error_message.html";$thankyou_page = "thank_you.html";/*This next bit loads the form field data into variables.If you add a form field, you will need to add it here.*/$first_name = $_REQUEST['first_name'] ;$last_name = $_REQUEST['last_name'] ;$pet = $_REQUEST['pet'] ;$dog = $_REQUEST['dog'] ;$cat = $_REQUEST['cat'] ;$other = $_REQUEST['other'] ;$other_text = $_REQUEST['other_text'] ;$date = $_REQUEST['date'] ;$time = $_REQUEST['time'] ;$reason = $_REQUEST['reason'] ;$email = $_REQUEST['email'] ;$email2 = $_REQUEST['email2'] ;$phone = $_REQUEST['phone'] ;$phone2 = $_REQUEST['phone2'] ;// If the user tries to access this script directly, redirect them to the feedback form,if (!isset($_REQUEST['email'])) {header( "Location: $feedback_page" );}// If the form fields are empty, redirect to the error page.elseif (empty($first_name) || empty($last_name) || empty($pet)||empty($date)|| empty($time)|| empty($reason)) {header( "Location: $error_page" );}// If we passed all previous tests, send the email then redirect to the thank you page.else {mail( "$webmaster_email", "SCHEDULE AN APPOINTMENT REQUEST", $first_name, $last_name, $cat or $dog or $other, $other_text, $date, $time, $reason, $email or $phone, $email2, $phone2, "From: $first_name, $last_name" );header( "Location: $thankyou_page" );}?> __________________________________ Help! Quote Link to comment https://forums.phpfreaks.com/topic/280429-need-to-print-to-email-one-answer-from-group/ Share on other sites More sharing options...
cyberRobot Posted July 23, 2013 Share Posted July 23, 2013 Could you provide a little more information by what is meant by "...print the one item from each group..."? Are you looking to display what was submitted through the form on the Thank You page? If so, the form information needs to be passed to the Thank You page. Some solutions for passing data through the header redirect can be found here: http://stackoverflow.com/questions/11803343/how-to-pass-variables-received-in-get-string-through-a-php-header-redirect Quote Link to comment https://forums.phpfreaks.com/topic/280429-need-to-print-to-email-one-answer-from-group/#findComment-1441828 Share on other sites More sharing options...
goldie Posted July 23, 2013 Author Share Posted July 23, 2013 I DO want to be able to put the pet's name, date, and time into the thank you page. I will use the link you gave me for info. That is great! First, I just need to get it to email all the results. I'm confused how to get it to email one item from each group. For example, one group is the "species" group. I need it to email the id the user clicks on. They can choose dog, cat, or other. Do you see what I mean? I don't have the PHP set up correctly. Quote Link to comment https://forums.phpfreaks.com/topic/280429-need-to-print-to-email-one-answer-from-group/#findComment-1441832 Share on other sites More sharing options...
Solution cyberRobot Posted July 23, 2013 Solution Share Posted July 23, 2013 It looks like all the radio buttons are named "radio". Try clicking "Dog" on your form and then click "Email me". Note that "Dog" is no longer selected. You may want to review the following: http://www.tizag.com/htmlT/htmlradio.php Whatever you change the names to is what you would use for the $_REQUEST variables. Side note: I would also recommend the <label> tag: http://www.cyberscorpion.com/2012-02/making-html-forms-more-accessible-and-improving-usability-with-the-label-tag/ Quote Link to comment https://forums.phpfreaks.com/topic/280429-need-to-print-to-email-one-answer-from-group/#findComment-1441841 Share on other sites More sharing options...
goldie Posted July 23, 2013 Author Share Posted July 23, 2013 Okay. I see the problem. Thank you very much!! Quote Link to comment https://forums.phpfreaks.com/topic/280429-need-to-print-to-email-one-answer-from-group/#findComment-1441849 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.