Solved

PHP header auto refresh doesn't always work

Posted on 2014-11-06
5
383 Views
Last Modified: 2014-12-18
I have a login script where I do some integrity testing for the user submission. If all is fine, I set a session variable and do a refresh.  The code looks like this:

       $url = "https://mysite.com/index.php";
	header('refresh: 0; url='.$url); 
	exit; // to keep the rest of the form from continuing

Open in new window


What happens every once and a while (like 1 in 100) is that the auto refresh doesn't fire and since there isn't any text on the page it appears as if the page has frozen.

I just added this line which at least puts something up on the person's page. Otherwise all they got was a "white screen of death"...
      print 'Your page should auto refresh in two seconds. If not, please click this link: <a href="'.$url.'">'.$ur2.'</a>';

So now people at least see something other than the white screen.

Any insight on how to fix this so that it fires for everybody?
0
Comment
Question by:pkonstan1
  • 2
5 Comments
 
LVL 109

Assisted Solution

by:Ray Paseur
Ray Paseur earned 200 total points
ID: 40426863
Though it's deprecated by the W3, all browsers support the meta-refresh tag.  You can write this directly to the browser with an echo statement.
<meta http-equiv="refresh" content="0;URL='$url'" />

Open in new window

0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 300 total points
ID: 40427000
Since you are not doing a delayed refresh, you should probably just use 'Location' instead of 'refresh'.  http://php.net/manual/en/function.header.php
0
 
LVL 109

Assisted Solution

by:Ray Paseur
Ray Paseur earned 200 total points
ID: 40427036
0
 
LVL 58

Expert Comment

by:Gary
ID: 40507794
I've requested that this question be closed as follows:

Accepted answer: 500 points for Dave Baldwin's comment #a40427000

for the following reason:

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
php checkbox validation 5 27
PHP Installer 5 20
Number of hours between date in DB and now 8 16
Can't get container centered 4 12
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question