签到系统的php后台处理部分求解答
ITAS 2014-09-19 09:44:35 我想做的是点欢迎界面的按钮调用php后台处理数据,根据现在时间与数据库中上次签到时间的差值判断签到的情况。。但是现在就是即便可以判断,数据库也不按我的要求被修改。。。后面我会上其他页面的图片。。谢谢大家帮助我解答
<?php
$conn = odbc_connect("DRIVER={MySQL ODBC 5.2 Unicode Driver};
Server=localhost;Database=test","root","lzw0201");
$stu_id="12570219";//实际中由登陆表单获取;
//
$sql_select_time="select signin_time from signin where stu_id=$stu_id";
$sql_select_days="select con_days from signin where stu_id=$stu_id";
$sql_con_days="update signin set con_days=con_days+1,signin_time=$new_signin_time
where stu_id=$stu_id;";
$sql_signin_success="update signin set con_days=1,signin_time=$new_signin_time
where stu_id=$stu_id;";
$sql_date_diff="select datediff('$new_signin_time','$signin_time') as diffdate";
//
if (!$conn){
exit("Connection Failed: " . $conn);}
$rs=odbc_exec($conn,$sql_select_time);
while(odbc_fetch_row($rs))
{
$signin_time=odbc_result($rs,"signin_time");
//$con_days=odbc_result($rs,"con_days");
$new_signin_time=date("Y-m-d H:i:s",time());
$diffdate=mysql_query($sql_date_diff);
if($diffdate==0 or $diffdate<0){
header("Location:http://localhost:801/SignIn/noRepeat.html");
}else if($diffdate>0 and ($diffdate<1 or $diffdate==1)){
mysql_query($sql_con_days);
header("Location:http://localhost:801/SignIn/con_signinSuccess.php");
}else if($diffdate>1){
mysql_query($sql_signin_success);
header("Location:http://localhost:801/SignIn/signinSuccess.html");
}
}
odbc_close($conn);
?>