chriscloyd Posted December 8, 2008 Share Posted December 8, 2008 I'm have made a login script and now i have to process it i was trying to make it count to 10 like example Checking Admin 1 . 2 . 3 . 4 . 5 . 6 . 7 . 8 . 9 . 10 any one know how to actually make the numbers pop up while its counting to 10? Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted December 8, 2008 Share Posted December 8, 2008 Javascript Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted December 8, 2008 Author Share Posted December 8, 2008 theres a way in php i dont live javascript Quote Link to comment Share on other sites More sharing options...
flyhoney Posted December 8, 2008 Share Posted December 8, 2008 You could use flush() to flush the output buffer as you count. This isn't super classy or reliable and would make the login logic 10 times crazier <?php for ($x = 0; $x < 100; $x++) { echo $x; flush(); } ?> Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted December 8, 2008 Share Posted December 8, 2008 Code? Pretty much the only way you can output mid-execution like that in php is with flush(), otherwise you'd need javascript. edit: and nice ender's game quote poster above me Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted December 8, 2008 Share Posted December 8, 2008 there's a way in php i don't live javascript Nope, not without the page reloading, or using AJAX or it will just show 1 2 3 4 5 6 7 8 9 10 all at once. Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted December 8, 2008 Author Share Posted December 8, 2008 did that it just pops it up right away Checking Admin ...1...2...3...4...5...6...7...8...9... Quote Link to comment Share on other sites More sharing options...
flyhoney Posted December 8, 2008 Share Posted December 8, 2008 You are better off just displaying a loading gif. What you are asking to do requires javascript. Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted December 8, 2008 Author Share Posted December 8, 2008 nope i got it <?php echo 'Checking Admin ...'; ob_start(); for($i=1;$i<11;$i++) { if ($i == 10) { echo $i; } else { echo $i.'...'; } ob_flush(); flush(); usleep(900000); } ?> Quote Link to comment Share on other sites More sharing options...
flyhoney Posted December 8, 2008 Share Posted December 8, 2008 But what does this accomplish? You are forcing the user to wait? Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted December 8, 2008 Share Posted December 8, 2008 Not bad, but not good! It would be better to use javascript or AJAX to show a real time loading Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted December 8, 2008 Author Share Posted December 8, 2008 its just me that waiting its for a blog Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted December 8, 2008 Share Posted December 8, 2008 Might sound random, but why?? Why are you forcing yourself to wait? Doesn't make any sense. Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted December 8, 2008 Author Share Posted December 8, 2008 im not im making it check right now just testing crap out having fun im a patient person Quote Link to comment Share on other sites More sharing options...
flyhoney Posted December 8, 2008 Share Posted December 8, 2008 im a patient person Just made my day. Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted December 8, 2008 Author Share Posted December 8, 2008 opps lol didnt see that wow i guess i cant spell either ROFL Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted December 8, 2008 Author Share Posted December 8, 2008 opps lol didnt see that wow i guess i cant spell either ROFL Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted December 8, 2008 Author Share Posted December 8, 2008 <?php echo 'Checking Admin '; ob_start(); for($i=1;$i<6;$i++) { echo $i.' '; if ($i == 1) { $check_user = mysql_query("SELECT * FROM users WHERE username = '".$_POST['username']."' "); } if ($i == 2) { $num_users = mysql_num_rows($check_user); if ($num_users > 0) { $error = 0; } else { $error = 1; } } if ($i == 3) { if ($error == 0) { $check_user2 = mysql_fetch_assoc($check_user); } } if ($i == 4) { if ($error == 0) { if ($check_user2['password'] == md5($_POST['password'])) { $error = 0; } else { $error = 1; } } } if ($i == 5) { if($error == 0) { echo '<br>Login Succesful.<br> Being Redirected To Admin Page.'; $_SESSION['ccblog_admin'] = 'Chris Cloyd'; //header("Location: index.php"); } else { echo "<br>Could Not Log In.<br> Incorrect Information.<br> Being Redirected Back To The Home Page."; //header("Location: ../index.php"); } } ob_flush(); flush(); usleep(900000); } ?> Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted December 8, 2008 Share Posted December 8, 2008 Question? Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted December 9, 2008 Author Share Posted December 9, 2008 yes i have an answer? if ur asking why i did it this way just because i wanted to experiment and have fun Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted December 9, 2008 Share Posted December 9, 2008 No! I meant do you have a question or are you just randomly posting code. This is a help section on the forum, and normally is used to help people with there coding problems. Not just to show off code. Quote Link to comment Share on other sites More sharing options...
redarrow Posted December 9, 2008 Share Posted December 9, 2008 here what u was trying to create ajax with php progress bar http://www.devpro.it/upload_progress/ Quote Link to comment 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.