Location: PHPKode > projects > bloggeruniverse > ajaxlogin.php
<?php
ob_start();
session_start();
include("includes/config.php");
if (!$logged[username])
{
if ($_POST[login])
{
// the form has been submitted.  We continue...
$username = $_POST['username'];
$password = md5($_POST[password]);
// the above lines set variables with the submitted information.
$info = mysql_query("SELECT * FROM ".PREFIX."users WHERE username = '$username'") or print(mysql_error());
$data = mysql_fetch_array($info);
if($data[password] != $password)
{
// the password was not the user's password!
echo INCORRECT_LOGINCREDENTIALS;
}
else
{
// the password was right!
$query = mysql_query("SELECT * FROM ".PREFIX."users WHERE username = '$username'") or print(mysql_error());
$user = mysql_fetch_array($query);
// gets the user's information
if ($_POST['remember'])
{
setcookie("id", $user[id],time()+(60*60*24*5), "/", "");
setcookie("pass", $user[password],time()+(60*60*24*5), "/", "");
}
$_SESSION[id] = $user[id];
$_SESSION[pass] = $user[password];
// the above lines set 2 cookies. 1 with the user's id and another with his/her password.
echo LOGIN_SUCCESS;
}
}
}
else
{
echo ("Already Logged in");
}
?>
Return current item: bloggeruniverse