Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_php thread: Connection Handling/Redirect


Message #1 by "Kevin O'Connor" <mariotown@h...> on Thu, 28 Dec 2000 15:18:58 -0500
Hi!
The header() function by itself wouldn't work because I need to determine if 
the script has timed out before redirecting.  What I had started trying was 
to determine if the script has timed out using the connection_status() 
function.  When a connection timeouts, connection_status() should return a 
2, I believe.  So I tried something like this:

if(connection_status() == 2) {
     header ("Location: error.php");
}

But this didn't work.  The script timed out and I received a blank error 
page.  So then I tried this:

register_shutdown_function("shutdown");
function shutdown() {
	if(connection_status() == 2) {
		header("Location: error.php");
	}
}

But this didn't work.  What I thought it would do would be to run the 
function shutdown() when the script dies.  I still get a blank screen.  I'll 
keep trying.  Anymore ideas?

I could have also tried testing to see if connection_timeout() returned true 
on shutdown.  It didn't work either.

I also can't send more time to the set_time_limit() function because the 
server I am on is running in safe mode and won't allow that.

Let me know.  It seems like someone should know how to do this.

Thanks!
Kevin

>From: Gabriele Bartolini <angusgb@t...>
>Reply-To: "professional php" <pro_php@p...>
>To: "professional php" <pro_php@p...>
>Subject: [pro_php] Re: Connection Handling/Redirect
>Date: Fri, 29 Dec 2000 12:58:45 +0100
>
>At 15.18 28/12/2000 -0500, you wrote:
>>Hi!
>>I was having some trouble trying to redirect to another page (an error
>>page) after a script times out and was wondering if anyone has done
>>this.  I have done redirects in PHP4 before so I know all the pitfalls to
>>look out for. Right now I have error_reporting set to to 0 so there aren't
>>any error messages displayed, but I don't want to see a blank page...I
>>want to see my error page.
>>
>>Anybody got any ideas or sample code they could reply with?
>
>Ciao Kevin, I don't know if I have understood your problem. And my solution
>seems to be pretty easy, but have you tried to send an HTTP header command,
>containing the directive 'Location'?
>
>For instance, let's suppose your URL for error managing is
>http://www.foo.com/error.php, you can write this:
>
><?php
>...
>Header('Location: http://www.foo.com/error.php');
>die;
>
>...
>?>
>
>Of course, Header must be sent before anything else ... (spaces included)
>
>Let me know
>-Gabriele
>
>--
>Gabriele Bartolini, Web Programmer
>angusgb@t... | http://space.tin.it/io/gabrbart
>"The box said 'Requires Windows 95 or better.'
>  I can't understand why it won't work on my Linux computer"


--- 
NEED TECHNICAL TIPS, TOOLS, AND INSIGHTS?  Is FREE okay?
Visit EarthWeb for the latest in IT Management, Software Development, 
Web Development, Networking & Communications, and Hardware & Systems.  
Click on http://www.earthweb.com for FREE articles, tutorials,
and discussions from the experts.
---
You are currently subscribed to pro_php as: $subst('Recip.EmailAddr')
To unsubscribe send a blank email to leave-pro_php-$subst('Recip.MemberIDChar')@p2p.wrox.com

  Return to Index