Jump to content


Photo

question regarding delay


  • Please log in to reply
3 replies to this topic

#1 shibbi3

shibbi3
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 11 October 2006 - 08:36 PM

hi everyone,

I was just wondering if anyone knows how to do the following:

Right now I have a form setup and when the user submits it, I want a new page to come up that says 'FORM SUBMITTED THANK YOU', and then after a 5 second delay it auto redirects the user back to the main page say 'index.php'...

Im not sure if this is a php problem... does anyone know?

My form is the following:

<form method="post" action="<?php echo basename($_SERVER["PHP_SELF"]); ?>" enctype="application/x-www-form-urlencoded"><div>
  <p><b>Name:</b><br /><input type="text" name="name" value="<?php if (isset($name)) echo htmlentities(stripslashes($name)); else echo ""; ?>" size="35" /></p>
  <p><b>E-mail:</b><br /><input type="text" name="email" value="<?php if (isset($email)) echo htmlentities(stripslashes($email)); else echo ""; ?>" size="35" /></p>
  <p><b>Subject:</b><br /><input type="text" name="subject" value="<?php if (isset($subject)) echo htmlentities(stripslashes($subject)); else echo ""; ?>" size="35" /></p>
  <p><b>Message:</b><br /><textarea name="text" cols="55" rows="12"><?php if (isset($text)) echo htmlentities(stripslashes($text)); else echo ""; ?></textarea></p>

  <br /><br />
  <p><input type="submit" name="form_submitted" value="OK - Submit" /></p>
  </div></form>


Everything is working except I want a new page to come up when its submitted and After a 5 second stop  on the new page, I want to redirect the user to the main page.

Thanks for any suggestions!

#2 roopurt18

roopurt18
  • Staff Alumni
  • Advanced Member
  • 3,749 posts
  • LocationCalifornia, southern

Posted 11 October 2006 - 08:45 PM

AFAIK you can't redirect with a delay in PHP; you'd need to use javascript or (not sure about this) a meta tag.
PHP Forms : Part I | Part II

JavaScript: Singleton

http://www.rbredlau.com

#3 alpine

alpine
  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 12 October 2006 - 04:30 AM


<?php

if(isset($_POST['form_submitted']))
{
// blah blah

echo <<<_HTML
<meta http-equiv="refresh" content="5; url=index.php" /> // send to index.php in 5 seconds
_HTML;

}

?>



#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 12 October 2006 - 02:22 PM

You can redirect with a delay with PHP. Use a header refresh:
header("Refresh: 5; URL=http://www.google.com");





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users