douchi1945 2013-07-17 09:44
浏览 36

联系表格与复选框几乎工作

I am having trouble displaying the correct answer/value picked in the contact form. The email received will only show C as an answer and not the picked choice.

<tr>
      <td><label for="gategory">Lemosine</label></td>
      <td><input type="checkbox" name="carchoice[]" value="A" /><td>
  </tr>
  <tr>
      <td><label for="gategory">Mini</label></td>
      <td><input type="checkbox" name="carchoice[]" value="B" /></td>
  </tr>
  <tr>
      <td><label for="gategory">Van</label></td>
      <td><input type="checkbox" name="carchoice[]" value="C" /></td>
  </tr>
  <tr>    
      <td><label for="gategory">Off-Road</label></td>
      <td><input type="checkbox" name="carchoice[]" value="D" /></td>
  </tr>
  <tr>
      <td><label for="gategory">Station-car</label></td>
      <td><input type="checkbox" name="carchoice[]" value="E" /></td>
  </tr>

And the PHP code

$check_box_values = "Check box value: ";
  if(isset($_POST['carchoice'])){
    foreach($_POST['carchoice'] as $value){
    $check_box_values .= $value;
    $check_box_values .= ', ';
  }
}


$msg=
  'Name:    '.$_POST['name'].'<br />
  Email:    '.$_POST['email'].'<br />
  IP:   '.$_SERVER['REMOTE_ADDR'].'<br /><br />

  IP:   '.$check_box_values['carchoice[]'].'<br /><br />

  Message:<br /><br />

  '.nl2br($_POST['message']).'

';

This is what i get in the email

Name:   awdawd aw
Email:  adasda@live.dk
IP:         195.249.185.254

IP:         C

Message:

awdawdawdd awd awdawd awd awd

Don't understand what i going wrong here?

  • 写回答

2条回答 默认 最新

  • drug95107 2013-07-17 09:50
    关注

    The value of check box is set as 'C' so C will be fetched, as you have labels on each try giving the label name in checkbox value.

    评论

报告相同问题?

悬赏问题

  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计