Well, Eins from JomPHP.com has request about PHP to me. I'm not very well in web AUTHOR. but i like to share my code. This sript is very usefull to web developer. .
Do you know:
Friendster is part of PHP, the script are very bad. Thus PHP has a lot malfunction. As fact, it serious problem with SPAMMER.But its ok.. all coding has own their weakness.
PHP login script : This simple php login script features functionsto add hashed and encrypted passwords and usernames to a mysql table,and then a function to validate users based on these PHP logincredentials. One of the most popular uses of a PHP script is to secure acess to various portions of a website based on a user's login name andpassword. We only use one way encryption, when storing the php login passwords in the mysql database, because this php login script neverneeds to know the actual plaintext of the username or password, there by securing the php login script.
<?
function MakeTableLogins($database, $host, $db_user, $db_pass) {//create the logins table
$linkID = mysql_connect($host, $db_user, $db_pass);
mysql_select_db($database, $linkID);
mysql_query("create table logins (user char(32), pasword char(32))", $linkID);
}
function Encrypt($string) {//hash then encrypt a string
$crypted = crypt(md5($string), md5($string));
return $crypted;
}
function AddUser($database, $host, $db_user, $db_pass, $username, $password) { //add user to table logins
$linkID = mysql_connect($host, $db_user, $db_pass);
mysql_select_db($database, $linkID);
$password = encrypt($password);
$username = encrypt($username);
mysql_query("insert into logins values ('$username', '$password')", $linkID);
}
function Login($database, $host, $db_user, $db_pass, $user, $password) { //attempt to login false if invalid true if correct
$auth = false;
$user = Encrypt($user);
$linkID = mysql_connect($host, $db_user, $db_pass);
mysql_select_db("$database", $linkID);
$result = mysql_query("select password from logins where user = '$user'", $linkID);
$pass = mysql_fetch_row($result);
mysql_close($linkID);
if ($pass[0] === (Encrypt($password))) {
$auth = true;
}
return $auth;
}
?> Do you have WordPress or other PHP platform? You can test it. Secure you PHP now!



5 comments:
Make login screen more secure? ok nice...
friendster memang php based...tapi diorang xleh lawan facebook...facebook guna php, ajax dll memang smart...
btw thanks for the article
Ajax aku tahu langsung. tapi pengaturcaraan ajax dah buat OS. Rujuk news [yang lama] pada forum mambang.org.my. kalau JomPHP ada maklumat ttg Av malaysia bagitahulah ya. GVR dan NVR dah bagus. saya tertarik dgn Mawar-Av. Tapi semenjak 20o8, blognya dah tak update. Sedih..
hmmm... this code seem to familiar with me somehow. where did you copy it?
fimiliar but not the same one..
But it okey if someone copy it..
I just share it.
By the way i got from my Yahoo Booter forumer friends. the forum is hehehe..secret..
Post a Comment
Subscribe to my Pod Cast Feed | Join me on Myspace.com
Regards,
MASOKIS (Programmer-Note.Blogspot.com)