Seaholme Posted August 5, 2013 Share Posted August 5, 2013 Hi, I'm struggling to solve what seems to be potentially quite a simple problem with my form! It's for a really basic web-based racing game, and basically the issue is that in the form, the option I've named "teamid" isn't sending any information forwards so $newteamid in the next section is always =0, which is the default in the MySQL database. I just don't know how to set it! I want the team id from the first part to send through into the second part. Is it possible to have the value of a form option set to being a variable like this?? //Find their teams and let them pick which team to use $findteams = mysql_query("SELECT * FROM team WHERE owner='$id'") or die(mysql_error()); echo "Select which team to race with:<br><form action='regional.php' method=post> <select name=teamid value=teamid> Team:"; while($row = mysql_fetch_array( $findteams )) { $teamid = $row['id']; echo "<option name=teamid value={$row['id']}>{$row['teamname']}</option>"; } echo '</select>'; echo "<bR><br>Is your team ready to go?<br><br><input type=submit name='stage1' value='Begin Race!'></form><br><br>"; if(isset($_POST['stage1'])) { $_POST['teamid'] = $newteamid; echo $newteamid; $startrace = @mysql_query("INSERT INTO regionals (teamid, stage, ownerid) VALUE ('$newteamid', '1', '$id')") or die("Error: ".mysql_error()); Please let me know if I need to explain or elaborate at all, I'd appreciate any help. Thanks guys! Quote Link to comment Share on other sites More sharing options...
PravinS Posted August 6, 2013 Share Posted August 6, 2013 (edited) check your isset part, it should be like this if (isset($_POST['stage1'])) { $newteamid = $_POST['teamid']; echo $newteamid; $startrace = @mysql_query("INSERT INTO regionals (teamid, stage, ownerid) VALUE ('$newteamid', '1', '$id')") or die("Error: ".mysql_error()); } Edited August 6, 2013 by PravinS Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.