简体   繁体   English

HTML选择表单,POST没有值

[英]Html select form, no value with POST

I am having problem and I spent lot of time trying to solve it but I couldn't find solution. 我遇到了问题,我花了很多时间试图解决它,但找不到解决方案。

So I got this HTML form: 所以我得到了这个HTML表单:

<form method="post" action="register.php" name="registerform">

<label for="signup_game_name">Game Name</label> <br>
<select id="signup_game_name" class="reg_input" size="1" name"game_id" required>

<option value="2">Game1</option>
<option value="3">Game2</option>

</select>
<br><br>



<label for="signup_input_teamname">Team name </label> <br>
<input id="signup_input_teamname" class="reg_input" type="text"  name="team_name" required /> 
<br><br>


<input type="submit"  name="register" value="Signup" /> </form>

I used php class (function) to generate "options" for select form (i just posted results of that function above). 我使用php类(函数)为选择表单生成“选项”(我刚刚在上面发布了该函数的结果)。 Its simple function: grab value from GET method and use it to get values from database and create "options" for select form. 它的简单功能:从GET方法中获取值,并使用它从数据库中获取值并为选择表单创建“选项”。

After i click submit button on my form I can use $_POST['team_name'] in my class but $_POST['game_id'] is unusable (its empty). 单击表单上的提交按钮后,我可以在班级中使用$_POST['team_name'] ,但$_POST['game_id']不可用(其为空)。 I get error: Notice: Undefined index: game_id 我收到错误消息: Notice: Undefined index: game_id

I know i am missing something but i cant find it. 我知道我想念一些东西,但找不到。

这是<select>标记中名称和“ game_id”之间的=符号:

<select id="signup_game_name" class="reg_input" size="1" name="game_id" required>

you are missing an = 您缺少=

<select id="signup_game_name" class="reg_input" size="1" name"game_id" required>

should be 应该

<select id="signup_game_name" class="reg_input" size="1" name="game_id" required>

one other thing... in your question you mention a function that uses GET to retrieve data, but your'e using POST in your form. 另一件事...在您的问题中,您提到了一个使用GET检索数据的函数,但是您在表单中使用POST Might want to check that too. 可能也想检查一下。

You forgot to put equals sign in "name": 您忘记在“名称”中添加等号:

name="game_id" NAME = “game_id”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM