Jump to content

Need to print to email one answer from group


goldie

Recommended Posts

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 = "[email protected]";

/*
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!

 

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

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.

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/

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.