Solved

PHP header auto refresh doesn't always work

Posted on 2014-11-06
5
466 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

726 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