$_POST variables for file "included" in 404 script
Posted: Thu Feb 21, 2008 11:24 am
This is a simplified example, so the reasons for the files being set up this way may not make sense to anyone, but they help to illustrate the problem.
Here are two files:
404.php (a custom Error 404 script)
login.php
The problem is that when typing a username and clicking Submit, the form redisplays instead of the success message. I don't understand why $_POST['name_submit'] isn't being transferred through the whole 404/include process.
Now you're probably wondering why I don't just use action="login.php" in the form, but in my real scenario that isn't an option.
Can anyone shed any light?
Here are two files:
404.php (a custom Error 404 script)
Code: Select all
<?php
include("login.php");
?>Code: Select all
<?php
echo '<html><body>';
if (isset($_POST['name_submit']))
{
echo 'You have submitted your username';
} else {
echo '<form action="' . $_SERVER['REQUEST_URI'] . '" method="post">';
echo 'Username: <input name="username" type="text" /><br />';
echo '<input name="name_submit" type="submit" value="Submit" />';
echo '</form>';
}
echo '</body></html>';
?>Now you're probably wondering why I don't just use action="login.php" in the form, but in my real scenario that isn't an option.
Can anyone shed any light?