MrXander Posted November 1, 2009 Share Posted November 1, 2009 Hi. Is there anyway to delay output displayed on a page? I'm using this as part of registering for my new website. While the script checks that what the user has created, I want a small delay (of around 5 seconds or so) then the output, either being "TRUE" or "FALSE" to be sent back, WITHOUT redirecting to another page. Any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/179853-delay-output/ Share on other sites More sharing options...
Alex Posted November 1, 2009 Share Posted November 1, 2009 You can get this effect by using JavaScript validation (make sure you're also validating by PHP) and timed events. Quote Link to comment https://forums.phpfreaks.com/topic/179853-delay-output/#findComment-948785 Share on other sites More sharing options...
MrXander Posted November 1, 2009 Author Share Posted November 1, 2009 Are you able to elaborate on that? I've checked out the link that you posted, but that would be with using a button, whereas I need this to display automatically and not in an alert box. Sorry if that sounds dumb :-) Quote Link to comment https://forums.phpfreaks.com/topic/179853-delay-output/#findComment-948790 Share on other sites More sharing options...
Alex Posted November 1, 2009 Share Posted November 1, 2009 If I understand you correctly, you want the user to enter information, press submit then in about 5 seconds output if it's valid or not? This seems like a very bad idea for many reasons.. But here's a basic example: <script type="text/javascript"> function validate(username) { var t = setTimeout("check('" + username + "')", 5000); } function check(username) { alert('It\'s been 5 seconds..'); } </script> <form action="" method="" onsubmit="return false;"> <input type="text" name="username" /> <input type="submit" value="submit" onclick="validate(this.form.username.value)" /> </form> Inside check() you'd want to perform any checks on the data.. Quote Link to comment https://forums.phpfreaks.com/topic/179853-delay-output/#findComment-948794 Share on other sites More sharing options...
MrXander Posted November 1, 2009 Author Share Posted November 1, 2009 All the validation has been done against the database. Basically, all I want is for a user to enter their information, press submit, then a new page loads saying "Please Wait" - then ~5 seconds later, text to show underneath showing "account created". Quote Link to comment https://forums.phpfreaks.com/topic/179853-delay-output/#findComment-948802 Share on other sites More sharing options...
Alex Posted November 1, 2009 Share Posted November 1, 2009 Then just use a similar concept to append text to a div 5 seconds after a page has loaded if the account was created. Quote Link to comment https://forums.phpfreaks.com/topic/179853-delay-output/#findComment-948806 Share on other sites More sharing options...
redarrow Posted November 1, 2009 Share Posted November 1, 2009 sleep(5); Quote Link to comment https://forums.phpfreaks.com/topic/179853-delay-output/#findComment-948867 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.