Jump to content

Archived

This topic is now archived and is closed to further replies.

chowwiie

login script using php..no need database...

Recommended Posts

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

Share this post


Link to post
Share on other sites
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, wait

EDIT:
Here
I consider that you already have a directory login setup
and your domain is http://localhost
so your login pages are at http://localhost/login/
now
1. 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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.