Jump to content

Need to print to email one answer from group


goldie
Go to solution Solved by cyberRobot,

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 = "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!

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • Solution

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/

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.