Jump to content

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/280868-simple-form-help-needed/
Share on other sites

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 by PravinS
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.