Solved

PHP header auto refresh doesn't always work

Posted on 2014-11-06
5
409 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 110

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 110

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
alert on input text 2 23
ASP sending two datas 2 22
html form layout 4 34
Echo values after a query in php 5 17
This article discusses four methods for overlaying images in a container on a web page
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
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…

740 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