Inseting Data

Hi folks
I’ve go a real headache of a problem that i cant understand, i have a username set in a session, which dislpays and works fine, so if they want to signup for a tournement all they have to do is enter there clan name and tourny they want, the only think that isnt working is that the session var isnt going into the database

Heres my signup page
[php]

<?php session_start(); ?>

<?php echo "Welcome $_SESSION[username]" ?>

QUBLan Registration

<?php $username = $_SESSION['username']; $db = mysql_connect("localhost", "root", "xxxxxxx"); mysql_select_db("xxxxxx",$db); ?>
Clan:
Torunement: <?php
 			$sql='select * from tourney';
 			$result=mysql_query($sql);
   			while($row=mysql_fetch_array($result))
     			{
	  		echo '<option value="';
	  		echo $row['name'];
	  		echo '"';
	  		echo '>';
	  		echo $row['name'];
	  		echo "n";
     			}
 	?>
	  </select> 
</td>  
<input type="submit" name="Submit" value="Submit"> 
<input name="Reset" type="reset" id="Reset" value="Reset">

 

[/php]

And heres my Insertpage
[php]

<?php session_start(); ?> <?php $db = mysql_connect("localhost", "root", "xxxxxxx"); mysql_select_db("xxxxx",$db);

?>

<?php echo "Welcome $_SESSION[username]"; $username = $HTTP_GET_VARS['$username']; $clan=addslashes($HTTP_POST_VARS['clan']); $tourney=addslashes($HTTP_POST_VARS['tourney']); if (!$clan) { echo 'You have not entered all the required details.
' .'Please go back and try again.'; exit; } $sql = "Insert INTO tsignup (username, clan, tourney) values ('".$username."', '".$clan."', '".$tourney."')"; $result = mysql_query($sql); ?>

Test

 

 

[/php]

All other data is going into the database apart from the username, can someone please help me before i loose my mind

Thank’s In Advance

Dee

You forgot to move the session variable user name into a working variable on the second page. You did it on the first and probably think it got sent with the form data… it didn’t (could have though as a hidden field) because it wasn’t included (scope of the variable is just for that page) , so when you go to use it in the second page it isn’t there.

Now did I just confuse you… Sorry. Long and short of it… use your session variable to reload it in the working variable rather then the $HTTP_GET_VARS and all should be well.

Sponsor our Newsletter | Privacy Policy | Terms of Service