php中传统验证与thinkphp框架
时间:2024-02-01 13:01:10|栏目:PHP教程|点击:0 次
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-01详解PHP防止直接访问.php 文件的实现方法
- 02-01PHP自定义函数判断是否为Get、Post及Ajax提交的方法
- 02-01PHP实现的Redis多库选择功能单例类
- 02-01PHP开发的微信现金红包功能示例
- 02-01php中传统验证与thinkphp框架
- 02-01PHP编程求最大公约数与最小公倍数的方法示例
- 02-01PHP实现上传多图即时显示与即时删除的方法
- 02-01详谈php ip2long 出现负数的原因及解决方法
- 02-01PHP+MYSQL 读写分离简单实战
- 02-01PHP数据类型转换(字符串转数字,数字转字符串)
阅读排行
推荐教程
- 02-01详解PHP防止直接访问.php 文件的实现方法
- 02-01PHP自定义函数判断是否为Get、Post及Ajax提交的方法
- 02-01PHP实现的Redis多库选择功能单例类
- 02-01PHP开发的微信现金红包功能示例
- 02-01php中传统验证与thinkphp框架
- 02-01PHP编程求最大公约数与最小公倍数的方法示例
- 02-01PHP实现上传多图即时显示与即时删除的方法
- 02-01详谈php ip2long 出现负数的原因及解决方法
- 02-01PHP+MYSQL 读写分离简单实战
- 02-01PHP数据类型转换(字符串转数字,数字转字符串)