Help Needed
Posted: Mon Apr 19, 2004 4:28 am
Hi there, I really would appreciate any help on this matter. Iam new with .php and what is written below is a login script that I ttok from internet. It works perfect as it is although it is not connected with database, but for a small website its OK. What I wanted to do is to modify it so each username and password has a designated page where to access and not always file.php.
Is it possible at all with this script or do I have to search for more.
Any help would be appreciated
Thanks
Is it possible at all with this script or do I have to search for more.
Any help would be appreciated
Thanks
Code: Select all
<?
//text
$text1 = "Field "username" or "password" is empty! Please fill in the form.";
$text2 = "Incorrect "username" or "password"!";
$file3 = "file.php"; //enter file to logon to
//username and password
##############################################################################
$username[1] = "demo"; // user1: demo
$password[1] = "demo";
$username[2] = "admin"; // user2: admin
$password[2] = "admin";
$username[3] = "test"; // user3: test
$password[3] = "test";
$username[4] = ""; // user4: ---
$password[4] = "";
$username[5] = ""; // user5: ---
$password[5] = "";
$username[6] = ""; // user6: ---
$password[6] = "";
$username[7] = ""; // user7: ---
$password[7] = "";
$username[8] = ""; // user8: ---
$password[8] = "";
$username[9] = ""; // user9: ---
$password[9] = "";
$username[10] = ""; // user10: ---
$password[10] = "";
##############################################################################
if (!$submit) {
?>
<html><head></head>
<body bgcolor="#EFEFEF">
<form action="<? $PHP_SELF ?>" method="GET">
<table width="300" align="Center" cellpadding="0" cellspacing="0" bgcolor="#ADC6D3" border="1" bordercolor="#3C9ED1"><tr><td>
<table align="Center" border="0" cellpadding="2" cellspacing="0">
<tr><td><font face="Verdana" size="-1">Username:</font></td><td><input name="user" type="Text" size="10"></td></tr>
<tr><td><font face="Verdana" size="-1">Password:</font></td><td><input name="pass" type="Password" size="10"></td></tr>
<tr><td colspan="2" align="right"><input name="submit" type="submit" name="submit" value="GO"></td></tr>
</table></td></tr></table>
</form></body></html>
<?
} else {
//check if fields are empty
if ($user == null || $pass == null) {
echo "<h4 align=center>$text1</h4>";
}
//check if username and passwords are correct
else {
if (
$user == $username[1] && $pass == $password[1] ||
$user == $username[2] && $pass == $password[2] ||
$user == $username[3] && $pass == $password[3] ||
$user == $username[4] && $pass == $password[4] ||
$user == $username[5] && $pass == $password[5] ||
$user == $username[6] && $pass == $password[6] ||
$user == $username[7] && $pass == $password[7] ||
$user == $username[8] && $pass == $password[8] ||
$user == $username[9] && $pass == $password[9] ||
$user == $username[10] && $pass == $password[10]
) {
include ("$file3");
}
//wrong username and password
else {
echo "<h4 align=center>$text2</h4>";
}
}
}
?>