Click to See Complete Forum and Search --> : PHP form trouble
MrJammin
05-30-2007, 10:51 PM
I have made a form that sends data to a PHP script using the post method. Everything works fine, but after the user presses submit they are taken to a blank page, essentially a page where the script has executed. I would like the user to be redirected back to a webpage of my choosing after they choose submit. How do I accomplish this? Also, If instead of that the form would just dissapear after the user presses submit that would suffice as well.
NogDog
05-30-2007, 11:46 PM
Either the form-handler script can output the desire HTML itself, or you can use the header() function (http://www.php.net/header) to send a Location: HTTP request to redirect to another page.
sanchez_1960
05-31-2007, 06:31 AM
I usually use <meta http-equiv="refresh" content="3;url=mypage.php"> rather a PHP method.
MrJammin
05-31-2007, 10:50 AM
Sanchez, where would that HTML code go in the page? Would it be contained in the form somewhere?
sanchez_1960
06-01-2007, 07:57 AM
Well, you're meant to put the tag in the meta area but it works anywhere.
Usuaully I have my forms working like this...
if ($POST)
{
// FORM EXECUTION PHP GOES HERE
echo '<meta http-equiv="refresh" content="3;url=mypage.php">';
}
else
{
require_once('myform.php');
}
ryeman98
06-01-2007, 08:07 PM
Are you putting the meta tag in the <head> section?
Also, for PHP, if you want a redirect, just use header(Location: http://somesite.com/index.php)
If you're doing that, you can't let the <head> section run at all or else the redirect won't work, and if you're redirecting, you shouldn't need the <head> section.