chowwiie Posted August 12, 2006 Share Posted August 12, 2006 hi... is it possible for me to create a login script using php without the need of a database? im kinda new in this business and i want to learn more... can somebody help me... please... or better give me an example.. tnx:D Link to comment https://forums.phpfreaks.com/topic/17320-login-script-using-phpno-need-database/ Share on other sites More sharing options...
Chetan Posted August 12, 2006 Share Posted August 12, 2006 It is not safe.I am not gonna make the script as its unsafe, i 1ce hd such a script.Ill just give the script to u, waitEDIT:HereI consider that you already have a directory login setupand your domain is http://localhostso your login pages are at http://localhost/login/now1. Create a directory users in the login directory.2. Here is your register script[b]Register.html[/b][code]<html><head><title>Register</title></head><body><b>Register</b><br><form action="Register.php" method="post">Username: <input type="text" name="un"><br>Password: <input type="password" name="ps"><br>Re-type Password: <input type="password" name="rps"><br><input type="submit" value="Register"><br></form></body></html>[/code]3. Here is register page[b]Register.php[/b][code]<html><head><title>Register</title></head><?php$un=$_POST['un'];$ps=$_POST['ps'];$rps=$_POST['rps'];if($ps==$rps){echo("<font color=blue>Password matched! </font> you may continue!<br>");if(file_exists("users/kaddu".$un."ismypass.bmp")){echo("<font color=red>Sorry but the username already exits</font>");exit();}else{$ps = sha1(md5($ps));}echo("<font color=blue>Adding your username and password to database</font>");$users = "users/kaddu".$un."ismypass.bmp";$ousers = fopen( $users, "a+" );fwrite( $ousers, $ps );fclose( $ousers );}}else{echo("<font color=red>Password does not match </font> Please return and retype the password correctly!");exit();}?></html>[/code]4. Now lets create a login script.[b]Login.html[/b][code]<html><head><title>Login</title></head><body><b>Login</b><br><form action="Login.php" method="post">Username: <input type="text" name="un"><br>Password: <input type="password" name="ps"><br><input type="submit" value="Login"><br></form></body>[/code]5. To login we need login.php[b]Login.php[/b][code]<html><head><title>Login</title></head><?php$un=$_POST['un'];$ps=$_POST['ps'];if(file_exists("users/kaddu".$un."ismypass.bmp")){$ps = sha1(md5($ps));$users = "users/kaddu".$un."ismypass.bmp";$ousers = fopen( $users, "a+" );$size = filesize($users);$ps2=fread( $ousers, $size );fclose( $ousers );if($ps==$ps2){echo("You are now logged in");}else{echo("<font color=red>Wrong Password!</font>");}}else {echo("<font color=red>Wrong Username!</font>");}?></html>[/code]Its not safe and you would have to code a lot even after you have done this to check weather someone is logged in or not, best thing to do is to use cookies after this Link to comment https://forums.phpfreaks.com/topic/17320-login-script-using-phpno-need-database/#findComment-73611 Share on other sites More sharing options...
Chetan Posted August 12, 2006 Share Posted August 12, 2006 I see you are a really new person at this and so you must understand that using MySQL would be better for you.and this is just an example of creatting a really secure login without using DBs, which is indeed not as secure. Link to comment https://forums.phpfreaks.com/topic/17320-login-script-using-phpno-need-database/#findComment-73612 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.