【问题标题】:Using checkboxes to pass info to next form使用复选框将信息传递到下一个表单
【发布时间】:2013-09-27 03:30:50
【问题描述】:

我运行一个查询

$querymail=mysql_query
("select sp.player_num as Pnum,concat(sp.first_name,' ',sp.last_name)as PName,
st.name as Team, sp.email_address as Email,spt_league_id as League, ss.Season_name
as Season from stats_player sp inner join stats_player_team stp,
stats_team st, stats_season ss 
where stp.player_num = sp.player_num and sp.email_address<>''
and st.team_num=stp.team_id and ss.season_index=stp.season_id and
ss.season_index=$this_season  order by st.name;");

然后输出到带有复选框的论坛/表格。

echo "<table border='1'>";
while($row=mysql_fetch_array($querymail))
{

echo "<tr><td><input type='checkbox' name='checkemail'
value=".$row'Pnum']."checked></td><td>".$row['PName']."</td><td>".$row['Email'].
"</td><td>".$row['Team'].' ' .$row['League'].' '.$row['Season']."</td></tr>";


}
echo "</table>";
echo "</form>";
}

然后它将该信息发送到另一个页面以显示信息,然后发送到选定的电子邮件地址。

我的查询很好,表格显示正确。 我不确定我是否真的通过复选框收集了正确的信息。这就是我需要帮助的地方。

我想收集每个检查项目的 sp.player_num 并传递到下一页。 然后,我将查找玩家编号和电子邮件,并为此设置电子邮件例程。但我似乎无法将任何内容传递到下一页。

我在 emailall.ph 中执行 print_r($_POST) 但它返回空。

在这种情况下我需要使用 Session_Start 吗?

【问题讨论】:

    标签: php post checkbox


    【解决方案1】:

    你需要有一个打开的form标签。

    echo "<form method='post' action='emailall.php'>";
    

    您需要将复选框设为数组,注意添加到名称字段的[]

    echo "<tr><td><input type='checkbox' name='checkemail[]'
    value='".$row['Pnum']."' checked></td><td>".$row['PName']."</td><td>".$row['Email'].
    "</td><td>".$row['Team'].' ' .$row['League'].' '.$row['Season']."</td></tr>";
    

    【讨论】:

    • 我确实有 echo "&lt;form name='email' method='post' Action='emailall.php'&gt;"; 当我将它复制到这里时它刚刚被修剪掉了。我在名称字段中添加了[],这使它起作用了!!!!!!非常感谢。
    猜你喜欢
    • 2013-04-23
    • 2021-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    相关资源
    最近更新 更多