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:
<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). Its simple function: grab value from GET method and use it to get values from database and create "options" for select form.
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). I get error: 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. Might want to check that too.
You forgot to put equals sign in "name":
name="game_id"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.