T.E. wrote:
Here's pseudocode of my php file:
<?php
if (isset($_POST['submit']))
{
if (isset($_POST['textbox']))
header("Location: otherpage.php"); //redirect to other page
}
?>
//else stay on the form page
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
Please enter something in the textbox
<input type="text" name="textbox" size="20">
<input type="submit" value="Submit" name="submit">
</form>
Hello, I would be happy to help :)
I guess it does not work when you press enter because the submit button
variable is not being sent with the form (right?). To counter this use
the code below:
You have to remove the if(isset($_POST['BUTTONNAME'])){ }
<?php
if (isset($_POST['textbox'])){
/* redirects to other page and exits */
header("location: otherpage.php");
exit;
}
?>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
Please enter something in the textbox
<input type="text" name="textbox" size="20" />
<input type="submit" name="submit" value="Submit" />
</form>
NOTE: I added an exit command after the header is sent. Not having this
is a severe security issue, since the server will execute all the code
below even if the client has been directed somewhere else.
Hope I helped ;).