Click to See Complete Forum and Search --> : simple php login needed!


metrosoccer12
08-10-2003, 11:51 AM
Okay I'm looking for the simplest php login i can find for my staff area....

I would like it to have unlimated user names and passes or a lot i should say.....

I want it to redirct to a certin page if login and pass are correct and redrict to another page if its incorrect

anyone know where i can find a simple one like this ooo and it has to be secure...

metrosoccer12
08-10-2003, 02:51 PM
hey i found one here but it seems i can only have 1 username and 1 password

http://forums.webdeveloper.com/showthread.php?s=&threadid=9950&highlight=password+protect

how do i make more?

xataku_nakusute
08-10-2003, 03:05 PM
how secure do you want it to be?
or..actually....what is it needed for?

metrosoccer12
08-10-2003, 03:12 PM
well im using it as a simple password protection to my news posting page not much damage could be done if someone accessed it... Also i might the code that says it protects my pages but it doesnt? anyone help?

metrosoccer12
08-10-2003, 03:27 PM
okay i well it does protect now but i still need to know how to add more users for the log in

metrosoccer12
08-10-2003, 03:51 PM
anyone know how to add more users??? xataku_nakusute do u?

pyro
08-10-2003, 05:15 PM
I believe this post covered that:

http://forums.webdeveloper.com/showthread.php?s=&threadid=11768#post63373Depending on how many you need, you may want to use a database, though...

metrosoccer12
08-10-2003, 05:21 PM
is the the whole page for passwordreader.php?

<?PHP
$x = 0;
$user = new array("user1inmd5encryptedformat","user2inmd5encryptedformat","user3inmd5encryptedformat"); //array of usernames
pass = new array("password1inmd5encryptedformat","password2inmd5encryptedformat","password3inmd5encryptedformat"); //array of passwords
for ($i=0; $i < count($user); $i++) {
if ($x == 0) {
if (md5($_POST['username']) == $user[$i]) {
if (md5($_POST['password']) == $pass[$i]) {
setcookie ("verified", true);
header ("Location:<a href="http://www.yoursite.com/dir/page.htm" target="_blank">http://www.yoursite.com/dir/page.htm</a>");
}
else {
echo "Incorrect password";
}
$x = 1;
}
}
}
if ($x == 0) {
echo "Incorrect username";
}
?>

pyro
08-10-2003, 05:24 PM
Yes, but not that the header is incorrect (just due to some formatting by these forums...) Just had to say that so no one gets confused... :)

metrosoccer12
08-10-2003, 05:30 PM
eh its screwed up..... heres the code im using......

<?PHP
$x = 0;
$user = new array("19ef8220eb60b97224a287cbaa2eda6d","user2inmd5encryptedformat","user3inmd5encryptedformat"); //array of usernames
pass = new array("MYPASSWORD","password2inmd5encryptedformat","password3inmd5encryptedformat"); //array of passwords
for ($i=0; $i < count($user); $i++) {
if ($x == 0) {
if (md5($_POST['username']) == $user[$i]) {
if (md5($_POST['password']) == $pass[$i]) {
setcookie ("verified", true);
header ("Location:<a href="http://www.krylonblue.net/easiertorun/staff/postnews.php" target="_blank">http://www.krylonblue.net/easiertorun/staff/postnews.php</a>");
}
else {
echo "<BODY bgColor=#24637C><font color=#dddee6><center>Incorrect Password</center></font>";
}
$x = 1;
}
}
}
if ($x == 0) {
echo "<BODY bgColor=#24637C><font color=#dddee6><center>Incorrect Password</center></font>";
}
?>


anyhelp? im kinda new with php

pyro
08-10-2003, 05:32 PM
Are both the usernames and passwords in MD5 hashes?

metrosoccer12
08-10-2003, 05:34 PM
eh?? what?

pyro
08-10-2003, 05:38 PM
Did you use http://www.infinitypages.com/scripts/encrypter.php to make your usernames and passwords? The script checks the password you typed in with a MD5 hash, so if you just typed the actual password in the array, it will not work. What you need to do is type it into the form at the link above and put that output in your script.

metrosoccer12
08-10-2003, 05:44 PM
yes i did that.... so anything else thats wrong? want me to give u the error? or w/e

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `'$'' in /home/krylon/public_html/easiertorun/staff/passwordreader.php on line 3

pyro
08-10-2003, 05:47 PM
pass should be $pass

metrosoccer12
08-10-2003, 05:54 PM
still no luck heres the code:


<?PHP
$x = 0;
$user = new array("19ef8220eb60b97224a287cbaa2eda6d","user2inmd5encryptedformat","user3inmd5encryptedformat"); //array of usernames
$pass = new array("MYPASSWORD","password2inmd5encryptedformat","password3inmd5encryptedformat"); //array of passwords
for ($i=0; $i < count($user); $i++) {
if ($x == 0) {
if (md5($_POST['username']) == $user[$i]) {
if (md5($_POST['password']) == $pass[$i]) {
setcookie ("verified", true);
header ("Location:<a href="http://www.krylonblue.net/easiertorun/staff/postnews.php" target="_blank">http://www.krylonblue.net/easiertorun/staff/postnews.php</a>");
}
else {
echo "<BODY bgColor=#24637C><font color=#dddee6><center>Incorrect Password</center></font>";
}
$x = 1;
}
}
}
if ($x == 0) {
echo "<BODY bgColor=#24637C><font color=#dddee6><center>Incorrect Password</center></font>";
}
?>

pyro
08-10-2003, 06:00 PM
Are you getting any error messages? Also, your header should look more like this:

header ("Location:http://www.krylonblue.net/easiertorun/staff/postnews.php");

metrosoccer12
08-10-2003, 06:15 PM
this is the error:

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `'$'' in /home/krylon/public_html/easiertorun/staff/passwordreader.php on line 3

metrosoccer12
08-10-2003, 07:07 PM
anyone....

pyro
08-10-2003, 07:10 PM
My bad... I must have written that when I was in a javascript mode. new array () should just be array () on lines 3 and 4

metrosoccer12
08-10-2003, 07:58 PM
works like magic! thanks a bunch!!!

pyro
08-10-2003, 08:20 PM
You're welcome, and sorry for the inconvience... ;)