Shoutbox

PHP Redirect - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: PHP Redirect (/showthread.php?tid=39487)

PHP Redirect by DJeX on 03-03-2005 at 11:21 PM

Ok, I have an upload code that uploads a song and creates a web page for that song. When the code is done running it want it to go to another page in the same window. Like a "Your song is now uploaded page". How would I redirect it to a new page when the code is done doing its thing?


RE: PHP Redirect by Concord Dawn on 03-03-2005 at 11:22 PM

Google or PHP.net.


RE: PHP Redirect by Plik on 03-03-2005 at 11:25 PM

As long as you havnt outputed any thing else you can use.

code:
header("Location: newpage");
But if you want it to show a message you could output a javascript redirect script with the page.
Or use a meta tag.
RE: PHP Redirect by L. Coyote on 03-03-2005 at 11:26 PM

If you haven't outputted text or cookies or the like, you can use header("Location: somepage.php")

If it gives you a "headers already sent" error, you'll have to use JavaScript or a meta tag.



Edit: :dodgy: Madman was faster :refuck:


RE: PHP Redirect by DJeX on 03-03-2005 at 11:49 PM

Yea it gives me a "headers already sent" error. So how would I activate the javascript redirect when the php is done? Would I just put it at the end of the PHP code out of the <?php ?> tags?


RE: PHP Redirect by L. Coyote on 03-03-2005 at 11:59 PM

quote:
Originally posted by DJeX
Would I just put it at the end of the PHP code out of the <?php ?> tags?
Yes, it can be put like that...
code:
<?
// php code
?>
<!-- javascript code -->
Or like this...
code:
<?
// php code
   if no error
?>
<!-- javascript code -->
<?
   else (some error happened)
   exit
?>

Edit: note I put pseudo-code (non-PHP), just to give you an idea of how it would look. That is not correct, and should be "translated" to PHP. I'm saying this just in case. :p
RE: PHP Redirect by fluffy_lobster on 03-04-2005 at 12:13 PM

* fluffy_lobster vomits on javascript

Google meta redirection :google: