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

try whit header("Location : page_name.php");

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.