okay guys ive got this page in which i want to verify the key that the user inputs with the key in my sql database, and then it updates a row called user_okay when i click on the enter button.

<?php session_start(); 

include ('dbc.php'); 

	//if ($_POST['Submit']=='Enter')
//	{
		$keys = rand(10000,99999);
		$id = $_SESSION['user_name'];
		mysql_query("UPDATE `users`  SET `key` = '$keys' WHERE `id` = '$id'") or 				die(mysql_error());
		$_SESSION['rkey'] = $keys;
		echo $_SESSION['rkey'];
		
		if ($keys == "$_POST('key')")
		{
			mysql_query("UPDATE `users`  SET `user_okay` = '1' WHERE `id` = '$id'				") or 				die(mysql_error());
		}
//	}

?>

<p>&nbsp;</p>
<table width="65%" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td bgcolor="d5e8f9" class="mnuheader"><strong><font size="5">Test</font></strong></td>
  <tr> 
    <td bgcolor="e5ecf9" ><form name="form1" method="post" action="" style="padding:5px;">
	   <p><br>
    	Time issued:
  		<input name="time" type="text" id="time">
    	</p>
    	<p>
    	<img src="pngimg1.php" align="middle">&nbsp; </p>
    	Please enter your coloured key:
  		<input name="key" type="text" id="key">
    	</p>
     	<p align="center"> 
      	<input type="Submit" name="Submit" id="Submit" value="Enter">
        </p>

however, when i click on the enter button, it always refreshes the page only. i would like to redirect the user to another page if my above action is successfull. Any idea?

after your update is successful you need to use

header("Location: nextpage.php");

make sure you have ob_start(); at the top of your document as well before anything else

This article has been dead for over six months. Start a new discussion instead.