...

View Full Version : Creating Login without Database



noXen
11-26-2003, 05:39 PM
I know that somehow i could create a secure login without using any databases. Someone told me that i could create a script that stores Username and Passwords using arrays. Is that 100% true? if so can someone kindly post the script here? Im not sure how to go about using arrays.

Thanks alot.

-noXen

SDP2006
11-26-2003, 10:58 PM
Sure, you could store them in arrays, but thats not really safe. I think the only really safe way is using the database. htaccess is pretty safe, but it all depends on what your protecting. If your protecting very confidential stuff, I'd use the database because its kinda hard to get into it. If your protecting stuff thats not really gonna harm anyone else to see, then use .htaccess.

The only really secure way I can think of is encrypt, using PHP's md5() function, your password into the database.

Hope this helps,

Steve

missing-score
11-26-2003, 11:16 PM
im not saying arrays is as secure as database, but surely if the info was stored as username/md5 password its gonna be just as hard to crack?

Nightfire
11-26-2003, 11:38 PM
htaccess is about just as safe as any other password protection too. Only way you're gonna get the password file is by brute force and if they gonna get it by brute force, then no password protection will work anyway as they'd (the script kiddies) would already be inside your webroot and could just download everything

noXen
11-27-2003, 03:06 AM
Well i just started learning php, so the guy who taught me the basics said using databases is very complicating. he advised me to use arrays since i would only have 10 logins and passwords MAXIMUM. Since my site doesnt have any very important information i think it doesnt need to be 100% secure.

If anyone can help me make a list of the 10 logins and passwords using arrays, such that i just need to fill in the logins and passwords, that would truely be useful.

PS: I would like it in php syntex please:D

Hope u guys could help.

Thanks!

-noXen

SDP2006
11-27-2003, 01:55 PM
I've never done it with arrays, but I have done it this way =


<?php
$username = $_POST['username'];
$password = $_POST['password'];
$actualusername = "noxen";
$actualpassword = "password";

if($username == $actualusername && $password == $actualpassword){
echo "You got in......";
}
else {
echo "Wrong password and/or username";
}
?>

noXen
11-27-2003, 02:10 PM
Thx guys for replying.

hey SDP2006, so if i have 10 logins and passwords i just keep adding this part?

$actualusername = "noxen";
$actualpassword = "password";


So meaning the code would look something like that for 10 users?



<?php
$username = $_POST['username'];
$password = $_POST['password'];
$actualusername = "noxen";
$actualpassword = "password";
$actualusername = "user2";
$actualpassword = "password";
$actualusername = "user3";
$actualpassword = "password";
$actualusername = "user4";
$actualpassword = "password";
$actualusername = "user5";
$actualpassword = "password";
$actualusername = "user6";
$actualpassword = "password";
$actualusername = "user7";
$actualpassword = "password";
$actualusername = "user8";
$actualpassword = "password";
$actualusername = "user9";
$actualpassword = "password";
$actualusername = "user10";
$actualpassword = "password";

if($username == $actualusername && $password == $actualpassword){
echo "You got in......";
}
else {
echo "Wrong password and/or username";
}
?>


Am i right? Thanks.

-noXen

SDP2006
11-27-2003, 02:19 PM
I'm not sure if that will work. You'll have to test it. :)

missing-score
11-27-2003, 06:41 PM
no, it wont, try:




<?php

$usr_username = $_POST['username'];
$usr_password = $_POST['password'];

$users = array();
$passwords = array();

$users[0] = 'user1';
$passwords[0] = 'pass1';

$users[1] = 'user1';
$passwords[1] = 'pass1';

for($i=0;$i<count($users);$i++){

if($users[$i] == $usr_username && $passwords[$i] == $usr_password){

// success

} else {

// failure

}

}

?>

noXen
11-27-2003, 07:07 PM
Thanks missing-score,

Will try that tomorrow morning, its 3am now:D

Hope it works. Thanks again!:thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum