Location: PHPKode > projects > Wiki Web Help > wwh-0.3.8/wwh/handlers/login.php
<?php
require_once("../config.php");

$user = $_POST['user'];
$pass = md5($_POST['pass']);
$ip=$_SERVER['REMOTE_ADDR'];

$sql = "SELECT * FROM user WHERE user_name = '$user' AND password = '$pass'";
$result = mysql_query($sql,$con)  or die("{'response':'Database Error'}");
if(mysql_num_rows($result)==0){
	echo "{'response':'Invalid Login, Please try again.'}";
	exit;
}

$uid = mysql_result($result, 0,'user_id');
$level = mysql_result($result, 0,'level');
if(mysql_num_rows($result) == 1){
	session_start(); 
	$_SESSION['uid'] = $uid;
	$_SESSION['level'] = $level;
	$json = "{'response':'ok','level':'$level','user':'$user','ip':'$ip', 'uid':'$uid'}";
	if(mysql_result($result, 0 , 'level') == 'admin')
		$_SESSION['admin'] = true;
}else{
	$json = "{'response':'Invalid Login, Please try again.'}";
}
echo $json;
?>
Return current item: Wiki Web Help