HTML“选择”不会发布到PHP

HTML“选择”不会发布到PHP,php,jquery,html,post,Php,Jquery,Html,Post,我试图在注册表单中添加一个基本的选择函数,将所选数据发布到PHP脚本中 我的问题是,当调用$_POST['nameofselect']时,php建议它找不到select 我的注册页面中的代码片段如下 <form class="form-signup" id="usersignup" name="usersignup" method="post" action="createuser.php"> <h2 class="form-signup-heading">

我试图在注册表单中添加一个基本的选择函数,将所选数据发布到PHP脚本中

我的问题是,当调用$_POST['nameofselect']时,php建议它找不到select

我的注册页面中的代码片段如下

<form class="form-signup" id="usersignup" name="usersignup" method="post" action="createuser.php">
        <h2 class="form-signup-heading">Register</h2>
        <input name="newuser" id="newuser" type="text" class="form-control" placeholder="Username" autofocus>
        <input name="email" id="email" type="text" class="form-control" placeholder="Email">

  <p>Favorite Car!: </p>
   <select name="cars">
   <option value="volvo">Volvo</option>
   <option value="saab">Saab</option>
     <option value="opel">Opel</option>
   <option value="audi">Audi</option>
  </select>

        <input name="password1" id="password1" type="password" class="form-control" placeholder="Password">
        <input name="password2" id="password2" type="password" class="form-control" placeholder="Repeat Password">

        <button name="Submit" id="submit" class="btn btn-lg btn-primary btn-block" type="submit">Sign up</button>
        <div id="message"></div>
      </form>
有什么建议吗?

那只是打字错误


在PHP代码中,您正在查找cars索引,但在HTML代码中,您正在使用car。

当我为此线程更改变量名称时,这实际上是一个错误,我修复了问题和代码,但仍然无法运行。@ChristopherAllen因此,请尝试使用var\u dump检查$\u POST内容。在执行var dump时,汽车没有出现,但其他一切正常。这怎么可能?Select在代码中明确定义为名称
<?php

echo $_POST['cars'];
?>
Notice: Undefined index: cars in /fakepath/createuser.php on line 3.