好得很程序员自学网
  • 首页
  • 后端语言
    • C#
    • PHP
    • Python
    • java
    • Golang
    • ASP.NET
  • 前端开发
    • Angular
    • react框架
    • LayUi开发
    • javascript
    • HTML与HTML5
    • CSS与CSS3
    • jQuery
    • Bootstrap
    • NodeJS
    • Vue与小程序技术
    • Photoshop
  • 数据库技术
    • MSSQL
    • MYSQL
    • Redis
    • MongoDB
    • Oracle
    • PostgreSQL
    • Sqlite
    • 数据库基础
    • 数据库排错
  • CMS系统
    • HDHCMS
    • WordPress
    • Dedecms
    • PhpCms
    • 帝国CMS
    • ThinkPHP
    • Discuz
    • ZBlog
    • ECSHOP
  • 高手进阶
    • Android技术
    • 正则表达式
    • 数据结构与算法
  • 系统运维
    • Windows
    • apache
    • 服务器排错
    • 网站安全
    • nginx
    • linux系统
    • MacOS
  • 学习教程
    • 前端脚本教程
    • HTML与CSS 教程
    • 脚本语言教程
    • 数据库教程
    • 应用系统教程
  • 新技术
  • 编程导航
    • 区块链
    • IT资讯
    • 设计灵感
    • 建站资源
    • 开发团队
    • 程序社区
    • 图标图库
    • 图形动效
    • IDE环境
    • 在线工具
    • 调试测试
    • Node开发
    • 游戏框架
    • CSS库
    • Jquery插件
    • Js插件
    • Web框架
    • 移动端框架
    • 模块管理
    • 开发社区
    • 在线课堂
    • 框架类库
    • 项目托管
    • 云服务

当前位置:首页>后端语言>PHP
<tfoot draggable='sEl'></tfoot>

php登录验证模板 php做登录验证

很多站长朋友们都不太清楚php登录验证模板,今天小编就来给大家整理php登录验证模板,希望对各位有所帮助,具体内容如下:

本文目录一览: 1、 怎么使用PHP PDO 写一个登录验证代码 2、 用php制作用户登录认证网页 3、 php中的验证码怎么弄 是smarty模板 4、 在Thinkphp中怎么做登陆的验证码 5、 php会员登陆验证怎么写啊? 怎么使用PHP PDO 写一个登录验证代码

<span style="font-size:18px;"><span style="font-size:18px;"><html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset="utf-8" />

</head>

<?php

session_start(); //初始化session变量

$username = $_POST['name'];          //接收表单提交的用户名

$password=md5($_POST['pwd']);   //接收表单提交的密码

class chkinput    //定义类

{              

var $name;

var $pwd;

function chkinput($x,$y) //定义一个方法

{

$this->name=$x; //将管理员名称传给类对象$this->name

$this->pwd=$y; //将管理员密码传给类对象$this->pwd

}

function checkinput()

{

include("conn.php");    //连接数据库文件

$sql=mysql_query("select username,password from admin where username='".$this->name."' and password='".$this->pwd."'",$conn);

$info=mysql_fetch_array($sql);        //检索管理员名称和密码是否正确

if($info==false) //如果管理员名称或密码不正确,则弹出相关提示信息

{                  

echo "<script language='javascript'>alert('您输入的管理员名称或密码错误,请重新输入!');history.back();</script>";

exit;

}

else //如果管理员名称或密码正确,则直接跳转到登陆成功后界面

{                            

echo "<script>window.location='home.php';</script>";

$_SESSION['admin_name']=$info['username'];    //将管理员名称存到$_SESSION[admin_name]变量中

$_SESSION['pwd']=$info['password'];            ////将管理员名称存到$_SESSION[pwd]变量中

}

}

}

$obj=new chkinput(trim($username),trim($password));      //创建对象

$obj->checkinput();         //调用类

?>

</html></span></span>

用php制作用户登录认证网页

将用户名和密码提交到指定的页面,如checkform.php,然后在该页面中以传来的用户名和密码为条件,在数据库中查找,如果有记录的话,成功登陆,如果没有,就说明没有该用户,活着用户名错误

php中的验证码怎么弄 是smarty模板

启用php.ini配置文件中的extension=php_gd2.dll扩展(打开php.ini配置文件,去掉行首的分号后重启Apache即可)

在Thinkphp中怎么做登陆的验证码

tp3.2.3中做的一个验证码的例子:

①模块Common/function:

function check_verify($code, $id = ""){

$verify = new \Think\Verify();

return $verify->check($code, $id);

}

②控制器中添加:

public function index(){

$this->display();

}

public function verify_show(){

$config = array(

'fontSize' => 30, // 验证码字体大小

'length' => 4, // 验证码位数

'useNoise' => false, // 关闭验证码杂点

'fontttf' =>'5.ttf',

'useImgBg' => true,

);

$Verify = new \Think\Verify($config);

$Verify->entry();

}

public function verify_check(){

$verify = I('post.code');

if(!check_verify($verify)){

$this->error("亲,验证码输错了哦!");

}else{

$this->success('验证码测试成功!');

}

}

③模板中index.html

<form action="/data/upload/help/202303/13/053cac8fd39835227e3bc03179b87443.'Index/VerifyCode/verify_check')}" method="post" class="form-horizontal">

<div class="form-group">

<label for="code" class="col-sm-2" >验证码</label>

<div class="col-sm-2" >

<input type="text" class="form-control" id="code" name="code" >

</div>

<div class="col-sm-5">

<img src="/data/upload/help/202303/13/053cac8fd39835227e3bc03179b87443.'Index/VerifyCode/verify_show')}" onclick="change_verify()" id="img" title="点击刷新">

</div>

</div>

<div class="form-group">

<button class="btn btn-primary col-sm-offset-2" type="submit">提交</button>

</div>

</form>

<script>

function change_verify(){

var url = "/data/upload/help/202303/13/053cac8fd39835227e3bc03179b87443.'Index/VerifyCode/verify_show')}";

$('#img').attr('src',url);

}

</script>

php会员登陆验证怎么写啊?

这是我写,你可以参考下``

<?

session_start();

//获取到用户的密码和用户名

$username=$_POST['loginname'];

$userpass=$_POST['loginpass'];

//调用数据库执行类

include_once "Connect.class.php";

$link=new Connect();

//查询是否有与之配对的信息,有返回1,没有返回0

$strsql="select * from user where username='$username' and userpass='$userpass'";

//echo $strsql;

$row = $link->execute($strsql);

//记录用户的名字,在后面的网页中保存

$_SESSION['sname']=$username;

//echo $_SESSION['sname'];

if($link->getnum($row)==1){

echo "<script>alert('登陆成功');location.href='usercenter.php';</script>";

}else{

echo "<script>alert('登陆失败');location.href='index.php';</script>";

}

?>

/*----------------------------*/

connnect.class.php

<?

/**

* 数据库的连接与各项基本操作

*

* 实现数据库 连接,并提供insert,update,delete等基本的数据库查询语句执行方法,

* 返回查询结果集或函数执行结果。

*

* @version V1.0,2005-07-26

*/

class Connect

{

/**

* @var Object $conn 数据库连接字

* @Access private

*/

var $conn;

var $result;

var $num; //查询所得记录数

var $error; //错误信息

var $row; //一条记录

var $insert_id; //自动增量值

/**

* 构造方法,根据给定的主机名,用户名,密码,数据库名建立与数据库的连接,

* 如果连接失败则抛出错误。

*

* @param String $host 数据库所在主机名或地址

* @param String $user 数据库上的一个用户名

* @param String $pwd 用户名对应的密码

* @param String $db 需要连接的库名

*

* @access public

*/

function Connect($host="localhost",$user="root",$pwd="",$db="shenglan") {

$this->conn = $this->mysql_db_connect($host,$user,$pwd,$db);

}

/**

* 执行一条sql语句,如果是查询语句,则返回一个以字段名为下标的二维数组;

* 如果是一条执行语句,则返回执行结果,执行成功返回true,失败返回false。示例如下:

* @param String $sql 需要执行的查询语句

* @return array 以字段名为下标的数组集合或者Boolean值

* @access public

*/

function execute($sql) {

if(strtolower(substr($sql,0,6))=="select")

{

//echo $sql;

return $this->Query($sql);

} else {

if($this->result = mysql_query($sql,$this->conn))

return true;

else

return false;

}

}

/**

* 取得上次查询所得数据的记录数

* @return int 查询所得记录数

* @access public

*/

function getNum() {

return $this->num;

}

/**

* 向指定的数据表中插入一条记录

* @param String $table 插入数据的数据表名

* @param Array $array 以字段名为下标的数组,如:<code>

*

* @return Boolean 插入成功返回true,失败返回false

*/

function insertSql($table,$array) {

$t1 = array();

$t2 = array();

foreach($array as $key=>$value) {

$t1[] = $key;

$t2[] = "'".$value."'";

}

$sql = "insert into ".$table." (".implode(",",$t1).") values (".implode(",",$t2).")";

//echo $sql;

if($this->execute($sql)) {

$this->insert_id = mysql_insert_id();

return true;

} else

throw new Exception("错误的SQL语句:".$sql);

}

/**

* 取得最用一个插入有自动增量字段的自动增量值

* @return int 最后一个自动增量值

* @access public

*/

function getInsertID() {

return $this->insert_id;

}

/**

* 删除给定表中的数据

* @param String $table 表名

* @param Array $array 删除条件,用法同function insertSql($table,$array) 中的参数$array

* @return Boolean

* @access public

*/

function delSql($table,$array) {

$t1 = array();

foreach($array as $key=>$value) {

$t1[] = $key."='".$value."'";

}

$sql = "delete from ".$table." where ".implode(" and ",$t1);

if($this->execute($sql))

return true;

else

throw new Exception("错误的SQL语句:".$sql);

}

/**

* 修改给定表中的数据

* @param String $table 表名

* @param Array $array 修改的字段名和值,用法同function insertSql($table,$array) 中的参数$array

* @return Boolean 修改成功返回true,失败返回false

* @access public

*/

function updateSql($table,$array,$where=0) {

$t1 = array();

foreach($array as $key=>$value) {

$t1[] = $key."='".$value."'";

}

$sql = "update ".$table." set ".implode(", ",$t1)." where ".$where;

if($this->execute($sql))

return true;

else

throw new Exception("错误的SQL语句:".$sql);

}

/**

* 返回最后一次Insert或Update操作受影响的数据行数

* @return int 行数

* @access public

*/

function getAffectedRows() {

return mysql_affected_rows();

}

/*************** private fucntions ********************/

/**

*连接数据库

*@access private

*/

function mysql_db_connect($host,$user,$pwd,$db) {

$conn = mysql_connect($host,$user,$pwd) or die(mysql_error());

mysql_select_db($db,$conn) or die(mysql_error());

return $conn;

}

/**

* 执行一句查询语句,返回一个以字段名为下标的数组集合

*

* @param String $sql 需要执行的查询语句

* @return Array 以字段名为下标的数组集合

* @access private

*/

function Query($sql) {

$array = array();

if(!$this->result = mysql_query($sql,$this->conn)) {

$this->num = 0;

return $array;

}

$this->num = mysql_num_rows($this->result);

for($i=0;$i < mysql_num_fields($this->result);$i++) {

$field[$i] = mysql_field_name($this->result,$i);

}

for($i=0;$i<$this->num;$i++) {

$parray = $this->getRow();

$array[$i] = $parray;

}

return $array;

}

/**

* 取得查询所得数据集中一条数据

* @return Array

* @access private

*/

function getRow() {

$array = array();

if($this->num==0)

return $array;

$fields = mysql_num_fields($this->result);

$this->row = mysql_fetch_array($this->result);// or die(mysql_error());

for($i=0;$i<$fields;$i++) {

$array[mysql_field_name($this->result,$i)] = $this->row[$i];

}

return $array;

}

}

?>

关于php登录验证模板的介绍到此就结束了,不知道本篇文章是否对您有帮助呢?如果你还想了解更多此类信息,记得收藏关注本站,我们会不定期更新哦。

查看更多关于php登录验证模板 php做登录验证的详细内容...

声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did194934
更新时间:2023-04-26   阅读:15次

上一篇: php导出pdf文件 php数据导出到excel

下一篇:php直播方案 php开发直播平台教程

最新资料更新

  • 1.php物业台账公式 物业台账是什么意思
  • 2.php查询模块 php函数查询
  • 3.php获取服务器环境 php获取服务器状态
  • 4.php提取css文件 php引用css文件
  • 5.长沙php就业怎样 2021年php就业班
  • 6.php带协议跳转 php跳转函数
  • 7.php数学函数 php中函数的定义
  • 8.PHP没有前景吗 php现在怎么样
  • 9.包含Zend转php的词条
  • 10.php压缩上传的图片 php上传图片文件
  • 11.php本地myaql工具 phpmysqlnd
  • 12.php系统源代码下载 php源码免费下载
  • 13.php下面有哪些技术 php运用的技术php开发有哪些实用的技术
  • 14.php加密12进 php加密解密
  • 15.铜仁php招聘信息 铜仁工作招聘信息
  • 16.php网站下载图片 网站的php文件下载
  • 17.PHP安装宽带办理 php网站安装
  • 18.php图片上传及显示 php 图片上传
  • 19.php如何接收对象 php怎么接收json数据
  • 20.php循环处理速度 phpforeach循环

CopyRight:2016-{hedonghua:year}{hedonghua:sitegs} 备案ICP:湘ICP备09009000号-16 {hedonghua:sitejym}
本站资讯不构成任何建议,仅限于个人分享,参考须谨慎!
本网站对有关资料所引致的错误、不确或遗漏,概不负任何法律责任。
本网站刊载的所有内容(包括但不仅限文字、图片、LOGO、音频、视频、软件、程序等)版权归原作者所有。任何单位或个人认为本网站中的内容可能涉嫌侵犯其知识产权或存在不实内容时,请及时通知本站,予以删除。

网站内容来源于网络分享,如有侵权发邮箱到:kenbest@126.com,收到邮件我们会即时下线处理。
网站框架支持:HDHCMS   51LA统计 百度统计
Copyright © 2018-2026 「好得很程序员自学网」
[ SiteMap ]