惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
博客园 - Franky
GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Jina AI
Jina AI
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
L
LangChain Blog
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
AI
AI
T
Troy Hunt's Blog
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
Attack and Defense Labs
Attack and Defense Labs

博客园 - 阿木戈多

佛经上讲的181条做人的道理 SQLite: Lean, Mean DB Machine 测试使用windows live write发文章 男人25岁前的忠告 闭关修炼了(打算出关了) IIS FAQ 快速驱除U盘病毒 去除KMPplayer2.9的驴头提示 HTTP错误代码解释 [翻译] PHP安全 一些有用的google入口 减少滚动条滚动次数,迅速启动电脑 php容易犯的21个错误 博客园又添新兄弟 无意中发现的,自己看吧 世界上最经典的18句话排行榜 发几张天台山的图片 用 PHP 读取和编写 XML DOM 一个查询网站收录排名的网址
函数总结
阿木戈多 · 2006-03-28 · via 博客园 - 阿木戈多

一,记录用户登录信息:

注册处理:

  1function check($name,$pwd){  //登录验证
  2$sql="select * from users where uname='$name'";
  3$result=mysql_query($sql);
  4$num=mysql_num_rows($result);
  5if($answer=mysql_fetch_array($result))
  6{
  7       if($pwd==$answer['pwd'])
  8          {
  9           $_SESSION['username']=$name;
 10           updatestatus($name);
 11         $lasttime=date("Y-n-j h:i:s");
 12        echo "<script>alert('登录成功');";
 13        echo "this.location.href='bbs.php';</script>";
 14          }
 15      else
 16         {
 17        echo "<script>alert('密码有误');";
 18       echo "this.location.href='login.php';</script>";
 19         }
 20}
 21else
 22{
 23  echo "你尚未注册,请<a href=\"register.php\">注册</a>后再登录";
 24}
 25}
 26function flag(){    //判断登录
 27if(!isset($_SESSION['username']) && $_SESSION['username']==""){
 28echo "你尚未登录,不能查看此页";
 29exit;
 30}
 31}
 32function checkreg($uid,$pwd,$pwd1,$email){ //注册
 33if($uid==""){
 34echo "用户名不能为空";
 35exit;
 36}
 37if($pwd==""){
 38echo "密码不能为空";
 39exit;
 40}
 41if($pwd1!=$pwd){
 42echo "两次密码不一致";
 43exit;
 44}
 45if(strstr($uid,"@")){
 46echo "不正确的邮箱格式";
 47exit;
 48}
 49$sql="select * from users where uname='$uid'";
 50print_r($sql);
 51$result=mysql_query($sql);
 52$nums=mysql_num_rows($result);
 53echo $nums;
 54$uid=htmlspecialchars($uid);
 55$pwd=md5($pwd);
 56$lasttime=date("Y-n-j h:i:s");
 57echo $lasttime;
 58if(empty($nums)){
 59$sql="insert into users(uname,pwd,email) values('$uid','$pwd','$email')";
 60print_r($sql);
 61$result=mysql_query($sql);
 62    if($result){
 63         $_SESSION['username']=$uid;
 64           echo $uid;
 65           updatestatus($uid);
 66    echo "<script>alert('注册成功');";
 67echo "this.location.href='bbs.php';</script>";
 68       }
 69  else
 70         {
 71   echo "<script language=javascript>alert('注册失败');";
 72  echo "javascript:history.go(-1)</script>";
 73           }
 74}
 75else
 76{
 77echo "此用户名已存在,请用其它的用户名<a href=\"register.php\">注册</a>";
 78}
 79}
 80function updatestatus($name){
 81//更新登录状态
 82$lasttime=date("Y-n-j h:i:s");
 83$ip=getenv("REMOTE_ADDR");
 84$sql="update users set status=status+1 where uname='$name'";
 85print_r($sql);
 86$result=mysql_query($sql);
 87$sql="select * from useronline where uname='$name'";
 88$result=mysql_query($sql);
 89$num=mysql_num_rows($result);
 90if($num>0)
 91{
 92$now=date("Y-n-j h:i:s");
 93$diff=strtotime($now- strtotime($last);
 94echo $diff;
 95$sql="update useronline set logintime='$nowtime' where uname='$name'";
 96print_r($sql);
 97$result=mysql_query($sql);
 98}
 99else
100{
101$sql="insert into useronline(uname,logintime,ip) values('$name','$lasttime','$ip') ";
102$result=mysql_query($sql);
103}
104}