0

I'm new at HTML/PHP and a doubt just came to my mind while developing a simple system to the company I work for.

After the user fill an HTML form and save it, I have a php page that saves the previous form information in my MySQL database. This PHP page displays a message if tha data has been saved correctly and after 5 seconds it redirects the user to my index.php. I used php header function to countdown the 5 seconds and redirect the user to index.php:

header("refresh:5,url= index.php"); /* Redirect browser */

That works perfectly on Google Chrome, but on IE it seems like it just understand the "refresh" part and completely ignore the "url" redirect, because it just refresh the current page, which gives me a few errors, of course.

My doubt is: php header function has compatibility problems with IE11 (or vice versa)? I know that I can use HTML to do the same thing, but is there a way to make the "url" from php header function works with IE11?

Thanks.

  • Possible duplicate of [PHP header redirection does not work on IE 8](http://stackoverflow.com/questions/12056436/php-header-redirection-does-not-work-on-ie-8) – swidmann Oct 06 '15 at 14:08
  • Possible duplicate of [How to make a redirect in PHP?](http://stackoverflow.com/questions/768431/how-to-make-a-redirect-in-php) – Popnoodles Oct 06 '15 at 14:09
  • 2
    Why are you making the user wait 5 seconds before they can get on with what they want to do? –  Oct 06 '15 at 14:11
  • @NigelAngel This form is going to be filled by some employees of our facility here in Brazil and, unfortunatelly, most of them do not have so much experience with computers, so I would like to make very clear for them when something works or goes wrong, thats why showing "Data has beens saved" for 5 secs. But if you have a better suggestion, I'd apprecite if you share it. Thanks. – Murilo Komirchuk Oct 06 '15 at 14:18
  • Flash messages; Show "data has been saved" on the next page. Waiting 5 seconds every time will be **really** annoying. –  Oct 06 '15 at 14:18
  • Also, if you've outputted "Data has been saved" how are you getting a header relocation to work? Headers have already been started. :/ –  Oct 06 '15 at 14:22
  • @NigelAngel I agree. I'll work on that. Thanks for the tip. – Murilo Komirchuk Oct 06 '15 at 14:33

2 Answers2

1

you can use it to refresh page

  <meta http-equiv="refresh" content="30; ,URL=http://www.metatags.info/login">

please use like this as suggested below

echo '<meta http-equiv="refresh" content="30; ,URL=http://www.metatags.info/login">'
Karthick Kumar
  • 2,349
  • 1
  • 17
  • 30
nileshkardate
  • 21
  • 1
  • 1
  • 7
0

That's not how you redirect in PHP (it's actually how you redirect in HTML, which isn't the same thing). Try;

header("Location: index.php");
Geoff Atkins
  • 1,693
  • 1
  • 17
  • 23
  • 2
    There are lots of same answers to this same question already on SO. It really doesn't need another. – Popnoodles Oct 06 '15 at 14:13
  • There are a lot of questions dealing with PHP header redirects, but none that I've seen that confuse HTML meta tag redirects with PHP like this. Explaining the confusion, and then helping the asker by giving the correction isn't going to harm SO is it? – Geoff Atkins Oct 06 '15 at 14:15
  • 2
    You have enough rep to comment on the question. – Popnoodles Oct 06 '15 at 14:17
  • @Popnoodles in spanish we should called you "quisquilloso". Search about it. And it's not an insult ! – Marcos Pérez Gude Oct 06 '15 at 16:49
  • @MarcosPérezGude Call it nit-picking if you must but I disagree. Posting answers just to gain rep is just not necessary. – Popnoodles Oct 06 '15 at 16:59
  • I agree with you. It's really true. But some people don't know how to search.... XD – Marcos Pérez Gude Oct 06 '15 at 17:05
  • If there is something wrong with the question, then it should be flagged and removed. I wasn't commenting on the question, I was answering it. – Geoff Atkins Oct 07 '15 at 07:09