0

I have a form, which on submit checks the data. if the data is invalid, I currently have it echoing text.

I want it to echo the text then pause and redirect.

I've tryed sleep(); but that causes the page to sleep on submit, wait x amount of seconds then continues without showing the echo's

Any idea of how to get around this

Kiee
  • 10,661
  • 8
  • 31
  • 56

2 Answers2

2

Send out your error message nromally and use a meta refresh to do the redirecting after x amount of seconds:

<?php

// your code that determines there is an error goes here

header('Refresh: 10;url=your_page.php');

echo $errorMessage;

The header() call is identical to this meta tag:

<meta http-equiv="refresh" content="10;URL='your_page.php'">
John Conde
  • 217,595
  • 99
  • 455
  • 496
2

A simple (although admittedly quite old fashioned) solution would be to output a meta refresh as a means of re-directing the user after a period of time. (Five seconds in the example below.)

<meta http-equiv="refresh" content="5;URL='http://dest.url/whereever/'">

This simply sits in the HTML head as per any other meta tag. (See the Wikipedia page for more information.)

John Parker
  • 54,048
  • 11
  • 129
  • 129