dsgs8208 2014-01-24 12:32
浏览 34

HTML POST的数字格式

I have an HTML form that use POST to send data to a php file. The form is created dynamically and has a number of check boxes that can change. There is a hidden piece of data sent which is the number of persons in the list - numberOfPersons.

enter image description here

The echo $personCount; line shows that the numberOfPersons is received but I am unsure that the format is correct because will only ever show the first checked name in the list that was posted.

Could it be that the receiving php file does not know that numberOfPersons is a number? Do I need to set the format to integer somehow? Or is there another error?

The file that receives the post looks like this:

$personCount=$_POST["numberOfPersons"];

echo $personCount;

for ($intLoop = 1; $intLoop <= $personCount; $intLoop++)
{
echo $intLoop;
echo"<br>";
}
  • 写回答

1条回答 默认 最新

  • dougang8233 2014-01-24 12:53
    关注

    if you set the name of the form element as an array...

    name="numberOfPersons[]" 
    

    for each of the check boxes then you can query the result posted using either var_dump or print_r to see what the post is producing.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度