adrianmak Posted January 26, 2016 Share Posted January 26, 2016 After a success form submission, I will display a message say Data has been submitted. Please wait for 3 seconds for page redirection I used php function sleep() i.e. echo "Data has been submitted. Please wait for 3 seconds for page redirection"; sleep(3); $session->redirect("./"); However message had never been echoed. It just delay 3 seconds and follow a page redirection Link to comment Share on other sites More sharing options...
Fokke Posted January 26, 2016 Share Posted January 26, 2016 Hi! How about redirect using JS? Here's some discussion regarding sleep() function: http://stackoverflow.com/questions/3078867/php-output-text-before-sleep Link to comment Share on other sites More sharing options...
BitPoet Posted January 26, 2016 Share Posted January 26, 2016 In web development, never use PHP's sleep function (the few exceptions to this rule are not worth mentioning). $session->redirect sets a location header and according status code. By its nature, the header is processed by the user agent before any content is displayed to the user. So you either redirect with a header or present content to the user. You have two possibilities: 1. Do your form processing early in the page and either set a meta http-equiv="refresh" header with timeout and destination or let javascript redirect to the page like Fokke suggested 2. Use an intermediate confirmation page that uses a meta refresh header and to which you pass the success message and the final target (not much different from the first, but it's often easier to work around the problem of already included HTML headers this way) Link to comment Share on other sites More sharing options...
LostKobrakai Posted January 26, 2016 Share Posted January 26, 2016 You're basically coding this logic on the server: - Put the string "…" in the response - wait 3 seconds - set redirect header for the response - send response to the user Link to comment Share on other sites More sharing options...
modifiedcontent Posted February 23, 2018 Share Posted February 23, 2018 I'd normally use: <meta content='3; URL = https://begone.com' http-equiv='Refresh' /> What would be the Processwire way to do that with $session->redirect? Still confused... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now