每日签到的功能,供大家参考,具体内容如下
首次签到获得一个积分,第二次签到获得2个积分,第三次签到获得3个积分,以此类推但是签到必须每天连续积分才可以递增,如果有中断再次签到时获得积分仍然从一开始递增;用户:用户名、计数、点数、签名时间
sign.html
!DOCTYPE html html lang=' en ' head meta charset=' UTF-8 ' title sign/title/head dycentinput type=' text ' name=' username ' button签到/button span id=' span '/span div table id=' box ' border=' 1 '/table/div/center/body/html脚本src=' http : jquery。1 .12 .量滴js '/script script $(function(){ $(“button”)).单击(function(){ var username=$(' : text ').val();$.ajax({ type:'post ',url:'admin.php ',数据: { username : username },dataType:'json ',success : function(RES){ if(RES . success==1){ $(' # span ').html(")签到成功');var str='trtd用户名/tdtd连续签到天数/tdtd总积分/TD/tr ';str=' trtd ' RES . msg。username '/tdtd ' RES . msg。count '/tdtd ' RES . msg。点'/TD/tr ';$('#box ').html(字符串);} } }) });})/scriptadmin.php
?服务器端编程语言(Professional Hypertext Preprocessor的缩写)标头(' content-type : text/html;charset=utf-8 ');$ pdo=新PDO(' MySQL :主机=localhost'dbname=databasename ',"根"、"根");$ PDO-exec(' set name utf8 ');$ username=$ _ POST[' username '];$sqlQuery='从用户中选择*,其中用户名=' $ username $ row=$ PDO-query($ sqlQuery)-fetch(PDO : fetch _ ASSOC);if($ row){ $ sign _ time=$ row[' sign _ time '];$ sign _ time=strtotime($ sign _ time);$ int=日期(' Y-m-d ');$ int=strtotime($ int);//5 $ int s=$ int 86400;//6 $ int _ s=$ int-86400;//4 //当天已签到if($ int $ sign _ time $ sign _ time $ ints){//echo '您已签到;} //昨天未签到,积分,天数在签到修改为1 if($ sign _ time $ int _ s){ $ count=1;$ point=1;$ sign _ time=date(' Y-m-d h :s : I ');$sqlRow='更新用户集计数=' $计数,点=' $点,sign_time='$sign_time ',其中username=' $ username $ RES=$ PDO-exec($ SQLRow);//回声'签到成功修改为1';} //请签到if($ int _ s $ sign _ time $ sign _ time $ int){ $ count=$ row[' count ']1;$ point=$ row[' point ']1;$ sign _ time=date(' Y-m-d h :s : I ');$ sqlupdate=' update user set count=' $ count ',point='$point ',sign_time='$sign_time ',其中username=' $ username $ RES=$ PDO-exec($ sqlup date);//回声'签到成功1';} } else { $ count=1;$ point=1;$ sign _ time=date(' Y-m-d h :s : I ');$sqlAdd='插入用户值(null,' $username ',' $count ',' $point ',' $ sign _ time ')';$ RES=$ PDO-exec($ SQladd);//回声'恭喜你签到成功- 1';} //////////////////////响应$sqlEnd='从用户中选择*,其中用户名=' $ username $ info=$ PDO-query($ sqlEnd)-fetch(PDO : fetch _ ASSOC);echo json_encode(数组(' success'=1,' msg '=$ info));死去;以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我们。