I need a timed delay, please.

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
Martin Pickering
php-forum Fan User
php-forum Fan User
Posts: 106
Joined: Fri Oct 17, 2003 8:00 am

Tue Dec 30, 2008 3:35 am

I have a password-protected page.
The password must begin with SAT
I want it to appear that the password is being searched for after it is typed in.
How do I introduce a delay after inserting the "checking.htm" page?
I want the "checking" GIF image to be displayed for 2 seconds before the final page is loaded.
You test it here: http://www.satcure.net/test/

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>
<body>
<?php 
$password = "x";
$rest1 = substr(($_POST["password"]),0,3);
   
if ($rest1=="SAT") {
   include("checking.htm");
   
//Delay required here
include("final.htm");

}
else
{
// Wrong password or no password entered display this message
if (isset($_POST['password']) || $password == "") {
  print "<p align=\"center\"><font color=\"red\"><b>Incorrect Password</b><br></font></p>";}
  print "<form method=\"post\"><p align=\"center\">Please enter your password<br>";
  print "<input name=\"password\" type=\"password\" size=\"25\" maxlength=\"10\"><input value=\"Login\" type=\"submit\"></p></form>";
}

?>
<BR>
</body>
</html>
Martin Pickering
php-forum Fan User
php-forum Fan User
Posts: 106
Joined: Fri Oct 17, 2003 8:00 am

Tue Dec 30, 2008 8:11 am

I should add that I've tried using delays with "sleep" and "while x <= 10000" but it seems that the structure of my script is not allowing such delays to work in the way I want.

Just to clarify what I'm trying to achieve:

1. A page appears asking for password.
2. A blank page appears with "Searching database.."
3. That disappears and the actual final page appears.

Any suggestions gratefully received (but I'm a PHP bozo and really need to be spoon-fed!)
User avatar
AeroX
php-forum Fan User
php-forum Fan User
Posts: 140
Joined: Sun May 11, 2008 1:40 am
Location: London, UK
Contact:

Thu Jan 22, 2009 6:45 am

you could use

Code: Select all

header( "Location: [new page]" );
Or

Code: Select all

$time = time();
while( 1 )
{
    if( time() >= ($time+2) ) // 2 Seconds
        break;
}

// time delayed code
User avatar
gesf
Moderator
Moderator
Posts: 1716
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden
Contact:

Tue Jan 27, 2009 4:34 pm

Just sleep ...
Post Reply