<?
function connect()
{
$con= mysql_connect('----','-----','-----') or die(mysql_error());
mysql_select_db('outsk_login',$con) or die(mysql_error());
}
connect();
function check_user($email, $pwd)
{
$sql="SELECT UserID
FROM users
WHERE email='".$email."' AND pwd=MD5('".$pwd."')
LIMIT 1";
connect();
$result= mysql_query($sql) or die(mysql_error());
if ( mysql_num_rows($result)==1)
{
$user=mysql_fetch_assoc($result);
return $user['UserID'];
}
else
return false;
}
function login($userid)
{
$sql="UPDATE users
SET UserSession='".session_id()."'
WHERE UserID='$userid'";
mysql_query($sql);
}
function logged_in()
{
$sql="SELECT UserID
FROM users
WHERE
UserSession='".session_id()."',
LIMIT 1";
$result= mysql_query($sql);
return ( mysql_num_rows($result)==1);
}
function logout()
{
$sql="UPDATE users
SET UserSession=NULL
WHERE UserSession='".session_id()."'";
mysql_query($sql);
}
function iplog($userid)
{
$sql="UPDATE users
SET IP = '".$_SERVER['REMOTE_ADDR']."'
WHERE UserID='$userid'";
$result = mysql_query($sql);
}
?>