hi
can anyone refer a good secure php login script please
thanks
php login scripts
-
- Posts: 3
- Joined: Wed Feb 16, 2005 7:20 am
This should be in your functions file, for example "f.php"
This one should be on top of login page
By cheking "in=1" then that user is logged in, and if in = 0 then user not logged in
This is html source for for login, place it wherever u want
Code: Select all
function check($u, $p){
$q = mysql_query("select * from user where `nick` = '$u'");
$n = mysql_num_rows($q);
$r = mysql_fetch_array($q);
if ($n == 0) return false;
else {
if ($r["password"] == $p)
return true;
}
}
Code: Select all
if (check ($nick, $password) == true){
$in = 1;
session_register("nick", "password", "in");
$username = mysql_fetch_array(mysql_query("SELECT * FROM user where `nick` = '$nick'"));
} else $in = 0;
Code: Select all
<form method="POST">
<input type="hidden" name="login" value="1">
<p align="center" class="meniu">
<input type="text" name="nick" size="16" style="font-family: Verdana; font-size: 8pt"></p>
<p align="center" class="meniu">
<input type="password" name="password" size="16" style="font-family: Verdana; font-size: 8pt"></p>
<p align="center" class="meniu">
<input type="submit" value="Log In" name="B1" style="font-size: 8pt; font-family: Verdana"></p>
<p align="center" class="meniu">[b]<span lang="lt">
[url=reg.php]Register[/url]</span>[/b]</p>
</form>
if u want not mysql based login, try to use this "f.php"
Simple, but this is only for one user, all other source is the same like in post before
P.S. do not forget to place includes in your login page:
Code: Select all
function check($u, $p){
$username= "somename";
$password= "somepassword"
if (($u == $username)&&($p == $password)) return true;
else {
return false;
}
}
P.S. do not forget to place includes in your login page:
Code: Select all
include("f.php");