Re: A faster way to Redirect pages
| From: | Pete James | Date: | Mon, 17 Mar 2003 17:47:36 +0000 |
| Subject: | Re: A faster way to Redirect pages | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-139989@lists.php.net to get a copy of this message | ||
header(), session_start(), etc. can go anywhere in a page (after any content) as long as you start the page using output buffering (ob_start()). Example (bad example) follows:
<?php
ob_start()
print this;
print that;
if ($forgot)
{
// oops need to redirect
header('Location: foo.php');
}
print this;
print that;
if ($forgot_again)
{
// need session
session_start();
}
etc.
Barajas, Arturo wrote:
Just clarifying a little. The header() function doesn't necessarily go at the top. You can make whatever operations you need, but as long as nothing is echoed to the browser, there's no problem. I mean: <? // Query to a database... //Real long process... header("Location: yournewpage.php?arg1=val1"); exit; ?> -- Un gran saludo/Big regards... Arturo Barajas, IT/Systems PPG MX (SJDR) (427) 271-9918, x448-----Original Message----- From: Oscar F [mailto:lists@webdevfm.com] Sent: Lunes, 17 de Marzo de 2003 11:34 a.m. To: Poon, Kelvin (Infomart) Cc: 'php-general@lists.php.net' Subject: Re: [PHP] A faster way to Redirect pages Kelvin, You can use <? header("Location:login.php"); exit; ?> If you want to do it with PHP. You have to put it at the top of the file, since no other information can be sent before the Location header. HTH, -Oscar F. Poon, Kelvin (Infomart) wrote:Hi, I know this topic was discussed but I deleted my previousmail so I can't goback and review them. My question is, is there a faster wayto redirecthtml pages other than just using <meta HTTP-EQUIV="REFRESH"CONTENT="1;URL=login.php"> ? Is there any way we can do that in php so that it redirect "FASTER"? Right now I set the redirect time to be1 sec, but forsome reason it still takes kind of long until it actuallyredirects, I waswondering if there is any other way I can do this faster. THanks a lot everyone, Kelvin-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php