php中传统验证与thinkphp框架
时间:2017-11-22 16:31:29|栏目:PHP编程|点击: 次
PHP(超文本预处理器)可用于小型网站的搭建,当用户需要注册登录是,需要与后台数据库进行匹配合格才能注册和登录,传统的方式步骤繁多,需要先连接数据库再用sql语句进行插入。
<?php
header("Content-type: text/html; charset=utf-8");
$conn =mysqli_connect("localhost","root","");
if (!$conn){
echo "<script>alert('连接失败!');history.go(-1);</script>";
}
mysqli_select_db($conn,"liuyanban");
mysqli_query($conn,'SET NAMES utf8');
$password=$_POST['password'];
$username=$_POST['username'];
$face="yellow.png";
$result=mysqli_query($conn,"SELECT username from user1 where username = '$username'");
$a=mysqli_num_rows($result);
if($a)
{
echo "<script language=javascript>alert('用户名已存在!');location.href='reg.html'</script>";
}
else
{
$sql = mysqli_query($conn,"INSERT INTO user1(username,password,face)VALUES('1' ,'2','yellow.png')");
if($sql)
{
echo "<script language=javascript>alert('注册成功!');location.href='login.html'</script>";
}
else
{
echo "<script>alert('注册失败!');location.href='reg.html'</script>";
}
}
?>
|
您可能感兴趣的文章
- 02-10windows服务器iis+php获得错误信息的配置方法
- 02-09通过PHP接入DeepSeek API的两种方法
- 02-07PHP调用DeepSeek API的完整指南
- 02-06PHP foreach引用变量导致的问题及其解决方案
- 02-02PHP使用puppeteer抓取JS渲染后的页面内容
- 01-17PHP SM4加密的实现
- 01-17PHP实现用户认证与权限管理的实现
- 01-10ThinkPHP中跨域请求设置的几种方式
- 01-09ThinkPHP中的接口的安全防护措施小结
- 01-03在ThinkPHP中实现文件上传的实用示例


阅读排行
推荐教程
- 11-23PHP 7安装使用体验之性能大提升,兼容性强,扩展支
- 11-22PHP自定义函数判断是否为Get、Post及Ajax提交的方法
- 11-23php中 == 和 === 的区别和应用说明
- 11-23隐藏PHP版本与PHP基本安全设置
- 11-23PHP+MYSQL 读写分离简单实战
- 11-22详解PHP防止直接访问.php 文件的实现方法
- 11-22PHP编程求最大公约数与最小公倍数的方法示例
- 11-22PHP实现上传多图即时显示与即时删除的方法
- 11-23PHP保留两位小数的几种方法
- 11-23nginx+php 打开php错误提示的方法