php提交表单,未捕获数据

时间:2016-07-21 21:22:27

标签: php

我从这个教程中学到的这个代码得到了这个代码但不在我这边,它基本上将数据从一个页面传输到另一个页面。 你能用变量,大小来找出问题吗?  其他一切都有效 谢谢

<form action= "form_script.php" method="POST">
  <p> Name : <input type ="text" name = "name" /></p>
  <p> Email : <input type ="text" name = "email" /></p

  <p>size: 
    <select name="size">
      <option value "small">small</option>
      <option value "medium">medium</option>
      <option value "large">large</option>
    </select>
  </p>

  <p>Gender :
    <input type = "radio" name ="gender" value ="Male"/> Male
    <input type = "radio" name ="gender" value ="Female"/> Female
  </p>

  <input type ="submit" name = "submit" value="submit Button"/>
</form>

on form_script.php

<?php
  $name =$_POST['name'];
  $email =$_POST['email'];
  $size =$_POST['size'];
  $gender =$_POST['gender'];

  print "<p>Name: $name </br> Email: $email </br>
  Size: $size </br>Gender: $gender </p>";
?>

3 个答案:

答案 0 :(得分:0)

将选项标签更改为: <option value="small"> small </option>

您忘记了=标志

答案 1 :(得分:0)

对于每个HTML属性(例如value),您必须使用=符号来指定值:

<p>size: 
    <select name="size">
         <option value="small">small</option>
         <option value="medium">medium</option>
         <option value="large">large</option>
    </select>
</p>

答案 2 :(得分:0)

尝试正确格式化HTML:

<form action="form_script.php" method="POST">
    <p> Name : <input type="text" name="name"/></p>
    <p> Email : <input type="text" name="email"/></p
    <p>size:
        <select name="size">
            <option value="small">small</option>
            <option value="medium">medium</option>
            <option value="large">large</option>
        </select>
    </p>
    <p>Gender :
        <input type="radio" name="gender" value="Male"/> Male
        <input type="radio" name="gender" value="Female"/> Female
    </p>
    <input type="submit" name="submit" value="submit Button"/>
</form>