博客
关于我
php实现简单的登录
阅读量:236 次
发布时间:2019-03-01

本文共 1632 字,大约阅读时间需要 5 分钟。

我用了bootstrap框架,不知为什么一直表单不能正常排序显示,不过主要学习php逻辑,先不纠结。

登录页:test.php

    
Bootstrap 101 Template

处理页:

produce_action.php

location.href='test.php'; alert('请输入用户名!');";}else if(is_null($pwd)||strlen($pwd) == 0){ echo "";}else{ echo "name= ".$name; echo "
pwd=".$pwd; if(!is_null($name)) $_SESSION['userId']=$name; echo "
session=".$_SESSION['userId'];}?>

当然,最好的是加入数据库操作。数据库操作在前面的blog中已经涉及了,读者可以去看看,把这一块也加上:

进阶版,增加数据库判断:

location.href='test.php'; alert('请输入用户名!');";}else if(is_null($pwd)||strlen($pwd) == 0){ echo "";}else{ $conn=mysql_connect("localhost", "root","root"); if(!$conn){ echo ""; return; } mysql_select_db("test",$conn); $sql = "select * from users where userName='".$name."'"; $info1=mysql_query($sql,$conn); if($row = mysql_fetch_object($info1)){ if($row->UserPwd==$pwd){ echo "登录成功!"; echo '
'; break; }else{ echo ""; break; } }else{ echo ""; }}?>

注意,这里的test要替换成数据库名,数据库里面要添加数据方便测试

转载地址:http://keft.baihongyu.com/

你可能感兴趣的文章
Nginx 学习总结(16)—— 动静分离、压缩、缓存、黑白名单、性能等内容温习
查看>>
Nginx 学习总结(17)—— 8 个免费开源 Nginx 管理系统,轻松管理 Nginx 站点配置
查看>>
Nginx 学习(一):Nginx 下载和启动
查看>>
nginx 常用指令配置总结
查看>>
Nginx 常用配置清单
查看>>
nginx 常用配置记录
查看>>
nginx 开启ssl模块 [emerg] the “ssl“ parameter requires ngx_http_ssl_module in /usr/local/nginx
查看>>
Nginx 我们必须知道的那些事
查看>>
Nginx 源码完全注释(11)ngx_spinlock
查看>>
Nginx 的 proxy_pass 使用简介
查看>>
Nginx 的配置文件中的 keepalive 介绍
查看>>
Nginx 结合 consul 实现动态负载均衡
查看>>
Nginx 负载均衡与权重配置解析
查看>>
Nginx 负载均衡详解
查看>>
nginx 配置 单页面应用的解决方案
查看>>
nginx 配置https(一)—— 自签名证书
查看>>
nginx 配置~~~本身就是一个静态资源的服务器
查看>>
Nginx 配置清单(一篇够用)
查看>>
Nginx 配置解析:从基础到高级应用指南
查看>>
nginx+php的搭建
查看>>