I have a form set up and working nearly perfectly. I am using the select option to either hide or display other text fields and their associated titles. For example, if option "1" is selected from the drop-down, the form will only display one text field. If option "2" is selected, the first text field is displayed along with a second field.
Two problems come from my current code.
The first problem: When using POST to send myself an e-mail with the data, it shows me the field values for Total Members (which are currently other field ID's) and I would prefer to be sent the options (1, 2, 3, etc). The second problem: Using POST to send myself an e-mail with the data, it simply does not show me ANY data for what the text fields (Driver_Name1, Driver_Name2, etc) contained.The email I receive looks like this:
Team Name: team name here
Team Leader: the team leader's name Team Leader's E-mail: my@email123.com Total Members: driver_name1_1,Driver_Name1 Members:Comments: whatever comments I make
What I want the e-mail to look like:
Team Name: team name here
Team Leader: the team leader's name Team Leader's E-mail: my@email123.com Total Members: 5 Members: Bob, George, Tom, Larry, DavidComments: whatever comments I make
I can't get the code for the form to display properly here. It can be viewed here: link removed
Here is the code I have in test_send.php for the actual work being done behind the scenes:
<?php
$name = $_REQUEST['Team_Name'] ;
$leader = $_REQUEST['Team_Leader'] ;
$email = $_REQUEST['Leader_Email'] ;
$members = $_REQUEST['team_members'] ;
$drivers = $_REQUEST['Driver_Name1,Driver_Name2,Driver_Name3,Driver_Name4,Driver_Name5'] ;
$comments = $_REQUEST['Comments'] ;
mail( "my@email.com", "Registration Form From $leader",
"Team Name: $name \r\nTeam Leader: $leader\r\nTeam Leader's E-mail: $email \r\nTotal Members: $members \r\n\Members: $drivers \r\n\r\nComments: $Comments", "" );
header( "Location: http://mysite.com/send.php" );
?>
EDIT Problem Solved
Thanks again to Tudor Constantin for nudging me in the right direction. I have solved all of my problems. Everything corrected was in the code for the send file.
<?php
$name = $_REQUEST['Team_Name'] ;
$leader = $_REQUEST['Team_Leader'] ;
$email = $_REQUEST['Leader_Email'] ;
$members = $_REQUEST['team_members'] ;
$comments = $_REQUEST['Comments'] ;
$drivers = $_REQUEST ['Driver_Name1'].', '. $_REQUEST['Driver_Name2'].', '. $_REQUEST['Driver_Name3'].', '. $_REQUEST['Dri开发者_如何学编程ver_Name4'].', '. $_REQUEST['Driver_Name5'] ;
if ( $team_members == "driver_name1_1,Driver_Name1" ) { $members1=1 ; }
elseif ( $team_members == "driver_name1_1,driver_name2_1,Driver_Name1,Driver_Name2" ) { $members1=2 ; }
elseif ( $team_members == "driver_name1_1,driver_name2_1,driver_name3_1,Driver_Name1,Driver_Name2,Driver_Name3" ) { $members1=3 ; }
elseif ( $team_members == "driver_name1_1,driver_name2_1,driver_name3_1,driver_name4_1,Driver_Name1,Driver_Name2,Driver_Name3,Driver_Name4" ) { $members1=4 ; }
elseif ( $team_members == "driver_name1_1,driver_name2_1,driver_name3_1,driver_name4_1,driver_name5_1,Driver_Name1,Driver_Name2,Driver_Name3,Driver_Name4,Driver_Name5" ) { $members1=5 ; }
if ( $members1 == "1" ) { $drivers = $_REQUEST ['Driver_Name1'] ; }
elseif ( $members1 == "2" ) { $drivers = $_REQUEST ['Driver_Name1'].', '. $_REQUEST['Driver_Name2'] ; }
elseif ( $members1 == "3" ) { $drivers = $_REQUEST ['Driver_Name1'].', '. $_REQUEST['Driver_Name2'].', '. $_REQUEST['Driver_Name3'] ; }
elseif ( $members1 == "4" ) { $drivers = $_REQUEST ['Driver_Name1'].', '. $_REQUEST['Driver_Name2'].', '. $_REQUEST['Driver_Name3'].', '. $_REQUEST['Driver_Name4'] ; }
elseif ( $members1 == "5" ) { $drivers = $_REQUEST ['Driver_Name1'].', '. $_REQUEST['Driver_Name2'].', '. $_REQUEST['Driver_Name3'].', '. $_REQUEST['Driver_Name4'].', '. $_REQUEST['Driver_Name5'] ; }
mail( "myemail", "Registration Form From $leader",
"Team Name: $name \r\nTeam Leader: $leader\r\nTeam Leaders E-mail: $email \r\nTotal Members: $members1 \r\nMembers: $drivers \r\n\r\nComments: $Comments", "" );
header( "Location: mysite" );
?>
Edit your code and concatenate the drivers like:
$drivers = $_REQUEST['Driver_Name1].' '. $_REQUEST['Driver_Name2'].' '. ...;
精彩评论