从表单发布

时间:2011-06-22 05:04:15

标签: forms email select post

我有一个表单设置并且几乎完美地工作。我使用select选项隐藏或显示其他文本字段及其关联的标题。例如,如果从下拉列表中选择选项“1”,则表单将仅显示一个文本字段。如果选择选项“2”,则会显示第一个文本字段和第二个字段。

我目前的代码有两个问题 第一个问题:当使用POST向我发送带有数据的电子邮件时,它会显示Total Members(当前是其他字段ID)的字段值,我更愿意发送选项(1,2,3)等)。 第二个问题:使用POST向自己发送包含数据的电子邮件,它根本不会显示任何文本字段(Driver_Name1,Driver_Name2等)包含的数据。


我收到的电子邮件如下:

团队名称:团队名称在这里
团队领导:团队领导的名字
团队负责人的电子邮件:my@email123.com
会员总数:driver_name1_1,Driver_Name1
成员:

评论:无论我做什么评论


我想要的电子邮件是什么样的:

团队名称:团队名称在这里
团队领导:团队领导的名字
团队负责人的电子邮件:my@email123.com
会员总数:5
成员:Bob,George,Tom,Larry,David

评论:无论我做什么评论


我无法在此处获取表单的代码以便正确显示。可在此处查看:已删除链接

以下是我在test_send.php中为幕后实际工作所做的代码:

<?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" );
?>

修改 解决问题

再次感谢都铎·康斯坦丁在正确的方向上推动我。我已经解决了所有问题。所有更正都在发送文件的代码中。

    <?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['Driver_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" );
?>

1 个答案:

答案 0 :(得分:0)

编辑代码并连接驱动程序,如:

$drivers = $_REQUEST['Driver_Name1].' '. $_REQUEST['Driver_Name2'].' '. ...;