How can I delay the execution of a block of code in php?
if ($qry->execute($leads)) {
echo'<div class="note success">' .
$_POST["first_name"] . ', Your entry was successful!
</div>';
// Set up email params
This code displays a “Successful” message then emails the users. After displaying the the message, I want to redirect the user.
Is this possible in PHP? Do I need to use JavaScript?
Thanks!
If you want to delay the execution of PHP code, you can use the sleep function. However, it appears that you want to delay a redirect for the client. You can do this with JavaScript,
<meta>refresh and theRefreshheader.Using the
Refreshheader:Using
<meta>refresh:Using JavaScript:
The best is to use a combination of these three, and also show a message for users that have disabled these redirection technologies with a link that allows them to click through manually.