Jump to content


Photo

Redirection but with HTML above?


  • Please log in to reply
5 replies to this topic

#1 extrovertive

extrovertive
  • Members
  • PipPipPip
  • Advanced Member
  • 235 posts

Posted 29 September 2006 - 04:36 AM

I'd like to redirect a URL in PHP but with something already output.

Like
<html>
<body>

<?php header("Location: http://www.domain.com"); ?>

Is it possible to pass that?

#2 alpine

alpine
  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 29 September 2006 - 04:45 AM

You can use the html-variant:

<meta http-equiv="refresh" content="0; url=http://www.domain.com" />

#3 extrovertive

extrovertive
  • Members
  • PipPipPip
  • Advanced Member
  • 235 posts

Posted 29 September 2006 - 05:16 AM

Ya, I thought of that, but isn't there a PHP way like using ob_flush or something?

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 29 September 2006 - 09:13 AM

Ya, I thought of that, but isn't there a PHP way like using ob_flush or something?

Yes that is correct:
<?php ob_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>Redirecting...</title>
</head>
<body>
You will be redirected to google in approx 2 secounds.
<?php header("Refresh:2; URL=http://www.google.com"); ?>
</body>
</html>
<?php ob_end_flush(); ?>


#5 u0206787@nus.edu.sg

u0206787@nus.edu.sg
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 29 September 2006 - 10:05 AM

Ya, I thought of that, but isn't there a PHP way like using ob_flush or something?

Yes that is correct:
<?php ob_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>Redirecting...</title>
</head>
<body>
You will be redirected to google in approx 2 secounds.
<?php header("Refresh:2; URL=http://www.google.com"); ?>
</body>
</html>
<?php ob_end_flush(); ?>


Instead of re-direct to a webpage in the internet, if I want to direct to another php page inside the same folder, what should the sytnax will be? thanks.

#6 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 29 September 2006 - 10:54 AM

change http://www.google.com to the path you want the user to be redirected to.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users