Jump to content

Archived

This topic is now archived and is closed to further replies.

shibbi3

question regarding delay

Recommended Posts

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:
[code]

<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>

[/code]

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!

Share this post


Link to post
Share on other sites
AFAIK you can't redirect with a delay in PHP; you'd need to use javascript or (not sure about this) a meta tag.

Share this post


Link to post
Share on other sites
[code]

<?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;

}

?>

[/code]

Share this post


Link to post
Share on other sites
You can redirect with a delay with PHP. Use a header refresh:
[code=php:0]header("Refresh: 5; URL=http://www.google.com");[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.