i want to go to my main page (main.php) after updating my records from update page (update.php). how can i do it? please help...
ram
Printable View
i want to go to my main page (main.php) after updating my records from update page (update.php). how can i do it? please help...
ram
You could use something like this....
PHP Code:header("location: main.php");
Using a header is correct.
If it's after a processing POST request, don't send any response data (make sure the PHP code starts at the very top of the file, and there is nothing being echo()'d or otherwise sent) and use a 303 redirection code to prevent the POST request from being cached by the browser:
This will ensure that the back and forward controls work correctly without any irritating "This page contains POSTDATA that has expired from cache" messages.PHP Code:header('HTTP/1.1 303 See Other');
header('Location: main.php');
But what about after the echoes? What if the update.php has some "Something is updated successfully!" and then pause for a moment and then redirect the the main.php? How do you guys do that?
Thanks.
You could use a refresh redirect.
EDIT: So i did Dclamp :)HTML Code:<!--4 = number of seconds until refresh-->
<meta HTTP-EQUIV="REFRESH" CONTENT="4; URL=main.php">
@Lintz: you used a Visual Basic comment,
php comment is:
or html comment:PHP Code://blah OR:
/* blah */
HTML Code:<!-- Comment -->
You should have it set to HTML code, and have the HTML comment since META is HTML not PHP ;)
come one, you know better, your smarter then that :P
if your problem is resolved, please select "Thread Tools > Set as Resolved", and give rep accordingly
Can't you see I did a bit of both, just like in your post :)
well now it looks like a child wrote that code. here, make it like this:
HTML Code:<!-- 4 = number of seconds until refresh -->
<meta HTTP-EQUIV="REFRESH" CONTENT="4; URL=main.php">
Oh please, Dylan! :rolleyes: The thread starter hasn't even responded yet.