Forum Moderators: coopster

Message Too Old, No Replies

Automatic Forwarding in PHP

         

wfernley

3:41 pm on Jul 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi everyone. I have a simple question.

I was wondering how I can get a php page to automatically forward to another page when a certain action is made. For example, a user logs in, I want the page to automatically forward to the main user page. Is is this possible?

Thanks :)

Wes

stevenmusumeche

4:06 pm on Jul 14, 2004 (gmt 0)

10+ Year Member



header("Location:theotherpage.php");

wfernley

5:12 pm on Jul 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For some reason that gives me a error that header information has already been sent. it points to an include file i have which is include ("includes/header.php");

that file contains my top navigation bar.

coopster

5:28 pm on Jul 14, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Remember that header() [php.net] must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP.

charlier

5:39 pm on Jul 14, 2004 (gmt 0)

10+ Year Member



On work around to the output before header problem is to use phps buffering system.

Use like:
<?
ob_start();
print "some html output";
header("Location:theotherpage.php");
$T = ob_get_contents();
ob_end_clean();
print $T;
?>

That way all output will be buffered until after the header has been sent.

wfernley

1:40 pm on Jul 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK great :) I will try that and see if I can get it to work. Thanks for the posts :)

Wes