展示:

注册.html

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link rel="stylesheet" href="style.css"><title>注册</title></head><body><div id="div1"><form enctype="\u4e00~\u9fa5" method="post" action="./login.php" name='form' id='form'><table><h2>注册</h2><tr><td><p><span>账号:</span><input type="text" class="input" name='user' id='user'></p></td></tr><tr><td><p><span>密码:</span><input type="password" id='pasd' class="input" name='pasd'></p></td></tr><tr><td><input class="buttorn" type="submit" name='submit' id='submit' value="注册"onclick="returncheck(form);"><input class="buttorn" type="reset" name='reset' id='reset' value="重填"></td></tr></table></form></div></body></html>

登陆.html

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link rel="stylesheet" href="style.css"><title>登陆</title></head><body><div id="div1"><form enctype="\u4e00~\u9fa5" method="post" name='denglu' action='./login2.php'><table><h2>登录</h2><tr><td><p><span>账号:</span><input type="text" name='username' class="input"></p></td></tr><tr><td><p><span>密码:</span><input type="password" name='password' pattern="\u4e00~\u9fa5" class="input"maxlength="9" autofocus></p></td></tr><tr><td><input class="buttorn" type="submit" value="登录" readonly="readonly"><a href="./注册.html"><inputclass="buttorn" onclick="window.location.href('./注册.html')" type="button" value="注册"readonly="readonly"></a></td></tr></table></form></div>
</body></html>

welcom.html

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link rel="stylesheet" href="style.css"><title>welcome</title><style></style>
</head><body><div id="div1"><h2>欢迎您!</h2></div>
</body></html>

style.css

#div1 {background-image: url(./form_bg.jpg);background-position: left top;width: 1431px;height: 717px;background-repeat: no-repeat;position: relative;
}body,
form,
h1,
p,
div {margin: 0px;padding: 0px;
}body {font-family: 微软雅黑;font-size: 12px;
}form {width: 600px;height: 400px;margin-top: 50px;margin-bottom: 50px;margin-left: auto;margin-right: auto;padding-left: 30px;position: absolute;left: 48%;top: 10%;
}h2 {text-align: center;;margin-top: 16px;margin-bottom: 16px;margin-left: -20px;margin-right: 150px;font-size: 40px;
}p {margin-top: 20px;
}span {width: 75px;display: inline-block;padding-right: 10px;text-align: right;
}.input {width: 200px;height: 18px;border: 1px solid #38a1bf;padding: 2px;
}#input {width: 100px;height: 24px;
}.buttorn {width: 100px;height: 30px;background-color: #93b518;margin-top: 20px;margin-left: 75px;border-radius: 3px;font-size: 18px;font-family: 微软雅黑;color: white;
}span {font-size: 20px;
}

login.php(注册用的)

<?php
header("Content-type:text/html;charest=utf-8");
session_start();if (!isset($_POST['user'])){echo "<script type='text/javascript'>alert('您的表单还没填完!');</script>";exit("错误执行");
}include('./connect.php');$user=$_POST['user'];
$pasd=$_POST['pasd'];$result2=mysqli_query($conn,'select * from denglu where username=$user');
if($result2){echo "<script type='text/javascript'>alert('已存在该用户!');</script>";
}
else{
$result3=mysqli_query($conn,"insert into denglu(id,username,password) values(null,'$user','$pasd');");
echo "<script type='text/javascript'>alert('注册成功!');</script>";
}
mysqli_close($conn);//关闭数据库
?>

login2.php(登陆用的)

<?PHPheader("Content-Type: text/html; charset=utf8");if(!isset($_POST["submit"])){exit("错误执行");}//检测是否有submit操作 include('./connect.php');//链接数据库$username = $_POST['username'];//post获得用户名表单值$passowrd = $_POST['password'];//post获得用户密码单值if ($name && $passowrd){//如果用户名和密码都不为空$sql = "select * from denglu where username = '$username' and password='$passowrd'";//检测数据库是否有对应的username和password的sql$result = mysqli_query($conn,$sql);//执行sql$rows=mysqli_num_rows($result);//返回一个数值if($rows){//0 false 1 trueheader("refresh:0;url=welcome.html");//如果成功跳转至welcome.html页面exit;}else{echo "用户名或密码错误";echo "<script>setTimeout(function(){window.location.href='login.html';},1000);</script>";//如果错误使用js 1秒后跳转到登录页面重试,让其从新进行输入}}else{//如果用户名或密码有空echo "表单填写不完整";echo "<script>setTimeout(function(){window.location.href='login.html';},1000);</script>";//如果错误使用js 1秒后跳转到登录页面重试,让其从新进行输入}mysqli_close($conn);//关闭数据库
?>

connect.php(连接数据库)

<?php
$dbhost = "127.0.0.1";
$dbuser = 'root';
$dbname = "denglu";  //数据库名称
$dbtable='denglu';
$dbpass = "";    //数据库密码
$conn=mysqli_connect($dbhost,$dbuser,$dbpass);
if($conn=mysqli_connect($dbhost,$dbuser,$dbpass)){echo "<script type='text/javascript'>alert('连接成功');</script>";
}
else{echo "<script type='text/javascript'>alert('连接失败');</script>";
}
$connt=mysqli_select_db($conn,$dbname);
?>

PHP+MySql注册登陆页面开发完整代码相关推荐

  1. Spring MVC + Spring + Hibernate + mysql 注册登陆入门实例

    Spring MVC + Spring + Hibernate + mysql 注册登陆入门实例 (1) 结构 (说明目的是要做在线聊天室的,也包含登陆注册部分,先用这部分做个例子)开发环境用的是ST ...

  2. dedeCMS 会员中心注册登陆页面 - 模板修改

    dedeCMS 会员中心:注册登陆页面(logo.版权信息等)的修改问题 一. 模板文件路径及修改业务: 文件名 member\templets\ 涉及页面 修改业务 涉及图片名称 reg-new.h ...

  3. php连接mysql实现简单注册登陆页面

    登陆页面index.html 注册页面 register.html 安装Mysql数据库后,用MySQL数据库管理页面phpmyadmin创建数据库和表单 浏览器输入:域名/phpmyadmin ,没 ...

  4. python 识别登陆验证码图片(完整代码)_python 识别登录验证码图片功能的实现代码(完整代码)...

    在编写自动化测试用例的时候,每次登录都需要输入验证码,后来想把让python自己识别图片里的验证码,不需要自己手动登陆,所以查了一下识别功能怎么实现,做一下笔记. 首选导入一些用到的库,re.Imag ...

  5. python 识别登陆验证码图片(完整代码)_Python 实现简单图片验证码登录

    如何实现,执行代码报错了 from PIL import Image from pytesseract import image_to_string, pytesseract pytesseract. ...

  6. 开发H5游戏练手, 黑暗堡垒-炼狱传奇H5 (一) 登陆界面开发

    项目介绍 使用JS lufylegend框架编写RPG游戏练手项目,首先展示几项目的效果图: 项目地址 https://github.com/mangenotwork/HABL-H5 介绍 lufyl ...

  7. webpack+react多页面开发架构

    项目已经升级为最新版本参考react-multi-page-app webpack在单页面打包上应用广泛,以create-react-app为首的脚手架众多,单页面打包通常指的是将业务js,css打包 ...

  8. JAVA_GUI之“注册登陆界面”

    目录 要求 实现效果: 代码: 要求 题目描述 编写一个 GUI 登录界面,如下图: 输入用户名.密码,         1.如果是第一次进入该界面,请点击"注册",自动将用户名和 ...

  9. react-beautiful-dnd实现拖拽排序+合并+拆分的功能(完整代码)

    页面效果 完整代码已上传到github:https://github.com/MeiJunNa/drag-and-sort 感谢此链接作者提供的灵感: 水平布局:https://codesandbox ...

最新文章

  1. 华为副总裁因家庭原因提出辞职…… 任正非:你可以离婚啊!
  2. Play 2.0 用户指南 - 模版引擎 -- 针对Scala开发者
  3. RTP与RTSP的区别
  4. Jar文件的小小总结(原创)
  5. ITK:将静态密集2D级别集可视化为高程图
  6. BAT集体升级云事业部,这背后都藏着哪些“小心思”?
  7. Android开发环境搭建全程演示(jdk+eclipse+android sdk)
  8. 网易资深Java架构师:java数组对象转为list集合
  9. java不同进程的相互唤醒_JAVA多线程之线程间的通信方式
  10. 整型索引查询mysql是不是快点_图解Mysql索引的数据结构!看不懂你来找我
  11. 图像局部特征(十五)--MSCR
  12. mips 系统桥_系统功能调用实现简单输入输出(mips)
  13. python NLP中文近义词
  14. 机器学习----误差逆传播算法(BP算法)中的参数更新估计式推导
  15. 手机感应器,方向东南西北指南针,前后左右旋转角度。
  16. struggle in webservices
  17. 苹果4计算机错误怎么办,苹果刷机失败卡在恢复模式怎么办?
  18. ForeSpider数据采集软件之链接抽取
  19. CRM IFD部署更换证书 - adfs证书更换
  20. managed-schema配置文件详解

热门文章

  1. 软件设计师教程(九)计算机系统知识-软件工程基础知识
  2. 2019年3月5日-MPU9250使用(二)
  3. WinDbg 命令学习 - !list
  4. 国际菜鸟网络露头 阿里2.49亿美元投资新加坡邮政
  5. 使用 Python 读取 json 格式文件并查重
  6. yyds,Win10真香!!!
  7. pytorch——基础
  8. Bugzilla使用说明
  9. ubuntu14.04搜狗输入法中文无法切换英文
  10. chrome浏览器表单自动填充默认样式-autofill设置