PHP and JavaScript code used in "Login" section

PHP and JavaScript code used in "Login" section




4. Login


The status was:










Enter your login details you added on the previous page and
test the login.

The success or failure will be shown above.











bgcolor="#FFFFFF" cellspacing="1" cellpadding="0">















Username:

VALUE SIZE="8" MAXLENGTH="16" tabindex="1">

Password:

name="password" size="8" tabindex="2" maxlength="8">

href="javascript:alert('The password must be between 4 and 8 characters long.')">Help

NAME="FormsButton2" VALUE="Test Login" ONCLICK="validateForm()" tabindex="3"
style="font-family: Verdana; font-size: 8pt">

href="javascript:alert('Click to save the details')">Help

Now move on
to the final section




 



Click here to view the PHP and JavaScript code
used for this page.



 






// version 1.1
if (isset($password)) // if a the password is set then the form has been submitted on login.php page
{
include("connect2db.php");

$username = $HTTP_POST_VARS['username'];
$password = $HTTP_POST_VARS['password'];

$qstr = "SELECT * from members where username ='$username' and password ='$password'";

$result = mysql_query($qstr);
// check login info is correct
if (mysql_num_rows($result)) echo "
**Successful Login**
";
else echo "
**Failed Login**
";
mysql_close();
}
else echo "
**No login attempted**
";
?>

Posted in |