日期:2014-05-16 浏览次数:20410 次
<?php
session_start();
require("inc/pdo.php");
//矫正时区差异
ini_set("date.timezone","Asia/Chongqing");
$time=date("Y-m-d H:i:s");
//获得客户端ip
$user_ip = $_SERVER["REMOTE_ADDR"];
$name=$_POST["name"];
$password=$_POST["password"];
emptyloginnull($name,$password);
//判断传值是否为空
function emptyloginnull($name,$password){
$functionName='';
$functionName="emptyloginnull";
if(!empty($name)&&!empty($password)){
//都不是空...
loginSQL($name,$password);
}else{
echo Msg($functionName);
}
}
function loginSQL($name,$password){
$functionName='';
$functionName=1;
global $dbc;
$md5PD=md5($b64=base64_encode($password));
$selectUser=$dbc->prepare("select name,password,loginnumber,loginstatus from nasdaouser where name=? and password=?");
$selectUser->execute(array($name,$md5PD));
$userNum=$selectUser->rowCount();
$res=$selectUser->fetch();
if($userNum==1){
loginSuecess($name,$res,$md5PD);
}else {
Msg($functionName);
}
}
//登录成功
function loginSuecess($name,$res,$md5PD){
$functionName='';
$functionName=0;
global $dbc,$user_ip,$time;
$loginlog=$dbc->prepare("insert into loginlog (name,password,ip,logintime,status,loginstatus) values(?,?,?,?,?,?)");
$loginlog->execute(array($name,$md5PD,$user_ip,$time,'0','0'));
$userLogin=$dbc->prepare("update nasdaouser set endlogintime=? where name=?");
$userLogin->execute(array($time,$name));
Msg($functionName);
}
function Msg($functionName){
echo $functionName;
switch($functionName){
case "emptyloginnull":
echo "不要调戏我好吗?系统也会数数的,你根本没有输入帐号与密码!!!";
break;
case 0:
echo "登录成功!";
break;
case 1:
echo "登录失败,请检查帐号密码是否输入错误!";
}
}
?>
var_dump(0 == "emptyloginnull");bool(true)