注册(html)
DOCTYPE html>
<html>
<head>
<title>注册title>
<link rel="stylesheet" href="register.css">
<meta name="content-type"; charset="UTF-8">
<style>
body
{
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
position: absolute; flex-direction: column; background-color: red; flex: 1;
width: 100%; height: 100%; background: url(WOW.jpg) no-repeat; background-size:100% 100%; background-attachment:fixed;
}
.bigBox
{
margin: 0 auto;
margin-top: 0;
padding: 20px 50px;
background-color: #00000090;
width: 400px;
height: 500px;
border-radius: 10px;
text-align: center;
}
.bigBox h1
{
color: white;
font-family: "Comic Sans MS";
}
.bigBox .loginButton
{
margin-right: 30px;
margin-top: 20px;
margin-bottom: 20px;
width: 100px;
height: 25px;
color: white;
border: 0;
border-radius: 20px;
background-image: linear-gradient(to right, #b8cbb8 0%, #b8cbb8 0%, #b465da 0%, #cf6cc9 33%, #ee609c 66%, #ee609c 100%);
}
.m-left{
margin-left: 40px;
}
.m-plc{
margin-right: 30px;
margin-top: 30px;
}
.bigBox .login_box {
position: relative;
width: 100%;
}
.bigBox .login_box input{
outline: none;
border: none;
width: 100%;
padding: 10px 0;
margin-bottom: 30px;
color: #fff;
font-size: 16px;
border-bottom: 1px solid #fff;
background-color: transparent;
}
.bigBox .login_box label{
position:absolute;
top: 0 ;
left: 0;
padding: 10px 0;
color: #fff;
pointer-events: none;
transition: all 0.5s;
}
.bigBox .login_box input:focus + label,
.bigBox .login_box input:valid + label{
top: -20px;
color: #f509e1;
font-size: 12px;
}
.b a{
position: relative;
padding: 5px 15px;
color: #fff;
text-decoration: none;
transition: all 0.5s;
}
.b a:hover {
color: #fff;
border-radius: 15px;
background-color: #c8f407;
box-shadow: 0 0 5px #c8f407,0 0 25px #c8f407,0 0 50px #c8f407,0 0 100px #c8f407;
}
.b a span{
position: absolute;
}
.b a span:first-child {
top: 0;
left: -100%;
width: 100%;
height: 2px;
background: linear-gradient(to right,transparent,#c8f407);
animation: move1 1s linear infinite;
}
.b a span:nth-child(2){
right: 0;
top: -100%;
width: 2px;
height: 100%;
background: linear-gradient(transparent,#c8f407);
animation: move2 1s linear 0.25s infinite;
}
.b a span:nth-child(3){
right: -100%;
bottom: 0;
width: 100%;
height: 2px;
background: linear-gradient(to left,transparent,#c8f407);
animation: move3 1s linear 0.5s infinite;
}
.b a span:last-child{
left: 0;
bottom: -100%;
width: 2px;
height: 100%;
background: linear-gradient(#c8f407,transparent);
animation: move4 1s linear 0.75s infinite;
}
@keyframes move1{
0%{
left: -100%;
}
50%,
100%{
left: 100%;
}
}
@keyframes move2{
0%{
top: -100%;
}
50%,
100%{
top: 100%;
}
}
@keyframes move3{
0%{
right: -100%;
}
50%,
100%{
right: 100%;
}
}
@keyframes move4{
0%{
bottom: -100%;
}
50%,
100%{
bottom: 100%;
}
}
.m-left{
margin-left: 30px;
}
style>
head>
<body>
<div class="bigBox">
<h1>注册页面h1>
<form action="注册2.php" method="post">
<div class="login_box">
<input type="text" name='Username' id='Username' required />
<label for="name" >Usernamelabel>
div>
<div class="login_box">
<input type="password" name='Password' id='Password' required="required">
<label for="pwd">Passwordlabel>
div>
<div class="login_box">
<input type="password" id="Re_Password" name="Re_Password" required="required">
<label for="rpwd">Re_Passwordlabel>
div>
<div class="login_box">
<input type="password" id="Code" name="Code" size="4" required="required">
<label for="yzm">Codelabel>
<a href="javascript:void(0)" onclick="document.getElementById('captcha_img').src='验证码.php?r='+Math.random()">
<img id="captcha_img" border='1' src='验证码.php?r=echo rand(); ?>' style="width:90px; height:30px" />
a>div>
<div style="color: white;font-size: 12px" >
div>
<div>
<input type="submit" id="register" name="register" value="注册" class="loginButton m-left">
<input type="reset" id="reset" name="reset" value="重置" class="loginButton">
div>
<div class="b">
<a href="登录1.php">
已有账号,去登录
<span>span>
<span>span>
<span>span>
<span>span>
a>
form>
div>
body>
html>
注册(php)
header("Content-type:text/html;charset=utf-8");
$link = mysqli_connect('localhost','root','');
mysqli_set_charset($link,'utf8');
mysqli_select_db($link,'login');
$name=$_POST['Username'];
$pwd=$_POST['Password'];
$rpwd=$_POST['Re_Password'];
$code = $_POST['Code'];
if (!$link) {
die("连接失败: " .mysqli_connect_error());
}
else if(strlen($pwd) < 5||strlen($pwd)>10){
echo"";
exit;
}
else if($rpwd != $pwd){
echo"";
exit;
}
else{
$sql="insert into user(name, password)values('$name','$pwd')";
}
if(!(mysqli_query($link,$sql))){
echo "";
}else{
echo "";
}
?>
```<?php
header("Content-type:text/html;charset=utf-8");
$link = mysqli_connect('localhost','root','');
mysqli_set_charset($link,'utf8');
mysqli_select_db($link,'login');
$name=$_POST['Username'];
$pwd=$_POST['Password'];
$rpwd=$_POST['Re_Password'];
$code = $_POST['Code'];
if (!$link) {
die("连接失败: " .mysqli_connect_error());
}
else if(strlen($pwd) < 5||strlen($pwd)>10){
echo"";
exit;
}
else if($rpwd != $pwd){
echo"";
exit;
}
else{
$sql="insert into user(name, password)values('$name','$pwd')";
}
if(!(mysqli_query($link,$sql))){
echo "";
}else{
echo "";
}
?>
登录(html)
DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<title>用户登录title>
<link rel="stylesheet" href="index_log.css" />
<style>
*{
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
position: absolute; flex-direction: column; background-color: red; flex: 1;
width: 100%; height: 100%; background: url(WOW.jpg) no-repeat; background-size:100% 100%; background-attachment:fixed;
}
.login{
margin: 0 auto;
margin-top: 0;
padding: 20px 50px;
background-color: #00000090;
width: 400px;
height: 350px;
border-radius: 10px;
text-align: center;
box-shadow: 0 15px 25px rgba(0, 0, 0, 0.4);
}
.login h1{
color: #fff;
margin-bottom: 30px;
}
.login .login_box {
position: relative;
width: 100%;
}
.login .login_box input{
outline: none;
border: none;
width: 100%;
padding: 10px 0;
margin-bottom: 30px;
color: #ffffff;
font-size: 16px;
border-bottom: 1px solid #fff;
background-color: transparent;
}
.login .login_box label{
position:absolute;
top: 0 ;
left: 0;
padding: 10px 0;
color: #fff;
pointer-events: none;
transition: all 0.5s;
}
.login .login_box input:focus + label,
.login .login_box input:valid + label{
top: -20px;
color: #f509e1;
font-size: 12px;
}
.b a{
position: relative;
padding: 5px 15px;
color: #fff;
text-decoration: none;
transition: all 0.5s;
}
.b a:hover {
color: #fff;
border-radius: 15px;
background-color: #c8f407;
box-shadow: 0 0 5px #c8f407,0 0 25px #c8f407,0 0 50px #c8f407,0 0 100px #c8f407;
}
.b a span{
position: absolute;
}
.b a span:first-child {
top: 0;
left: -100%;
width: 100%;
height: 2px;
background: linear-gradient(to right,transparent,#c8f407);
animation: move1 1s linear infinite;
}
.b a span:nth-child(2){
right: 0;
top: -100%;
width: 2px;
height: 100%;
background: linear-gradient(transparent,#c8f407);
animation: move2 1s linear 0.25s infinite;
}
.b a span:nth-child(3){
right: -100%;
bottom: 0;
width: 100%;
height: 2px;
background: linear-gradient(to left,transparent,#c8f407);
animation: move3 1s linear 0.5s infinite;
}
.b a span:last-child{
left: 0;
bottom: -100%;
width: 2px;
height: 100%;
background: linear-gradient(#c8f407,transparent);
animation: move4 1s linear 0.75s infinite;
}
@keyframes move1{
0%{
left: -100%;
}
50%,
100%{
left: 100%;
}
}
@keyframes move2{
0%{
top: -100%;
}
50%,
100%{
top: 100%;
}
}
@keyframes move3{
0%{
right: -100%;
}
50%,
100%{
right: 100%;
}
}
@keyframes move4{
0%{
bottom: -100%;
}
50%,
100%{
bottom: 100%;
}
}
.m-left{
margin-left: 30px;
}
.loginButton
{
line-height: 25px;
text-align: center;
margin-right: 30px;
margin-top: 10px;
margin-bottom: 30px;
width: 100px;
height: 25px;
color: white;
border: 0;
border-radius: 20px;
background-image: linear-gradient(to right, #b8cbb8 0%, #b8cbb8 0%, #b465da 0%, #cf6cc9 33%, #ee609c 66%, #ee609c 100%);
}
.register{
position: absolute;
right: 10px;
color: #ffffff;
font-size: 13px;
margin-bottom: 10px;
}
.c{
background-color: #00000090;
color: #fff;
box-shadow: 0 15px 25px rgba(0, 0, 0, 0.4);
}
.b{
margin-bottom: 20px;
}
style>
head>
<body>
<div class="login">
<h1>用户登录h1>
<form action="登陆2.php" method="post">
<div class="login_box">
<input type="text" name='Username' id='Username' required />
<label for="Username" >Usernamelabel>
div>
<div class="login_box">
<input type="password" name='Password' id='Password' required="required">
<label for="Password">Passwordlabel>
div>
<div class="b">
<a href="注册1.php">
注册账号
<span>span>
<span>span>
<span>span>
<span>span>
a>
div>
<div class="regiter">
<a href="注册1.php"><input type="submit" id="regiter" name="login" value="登录" class="loginButton m-left">a>
div>
div>
body>
html>
登录(php)
header("Content-type:text/html;charset=utf-8");
$link = mysqli_connect('localhost','root','');
mysqli_set_charset($link,'utf8');
mysqli_select_db($link,'login');
$name=$_POST['Username'];
$pwd=$_POST['Password'];
if (!$link) {
die("连接失败: " .mysqli_connect_error());
}
$sql = "select name,password from user where name='$name' and password='$pwd'";
$result=mysqli_query($link, $sql);
$row = mysqli_fetch_array($result,MYSQLI_BOTH);
$number = mysqli_num_rows($result);
if($number){
echo "";
}
else{
echo "";
exit;
}
?>
验证码(php)
ini_set('display_errors','off');
session_start();
$image = imagecreatetruecolor(100, 30);
$bgcolor = imagecolorallocate($image,255,255,255);
imagefill($image, 0, 0, $bgcolor);
$captcha_code = "";
for($i=0;$i<4;$i++){
$fontsize = 8;
$fontcolor = imagecolorallocate($image, rand(0,120),rand(0,120), rand(0,120));
$data ='abcdefghigkmnpqrstuvwxy3456789';
$fontcontent = substr($data, rand(0,strlen($data)),1);
$captcha_code .= $fontcontent;
$x = ($i*100/4)+rand(5,10);
$y = rand(5,10);
imagestring($image,$fontsize,$x,$y,$fontcontent,$fontcolor);
}
$_SESSION['authcode'] = $captcha_code;
for($i=0;$i<200;$i++){
$pointcolor = imagecolorallocate($image,rand(50,200), rand(50,200), rand(50,200));
imagesetpixel($image, rand(1,99), rand(1,29), $pointcolor);
}
for($i=0;$i<4;$i++){
$linecolor = imagecolorallocate($image,rand(80,220), rand(80,220),rand(80,220));
imageline($image,rand(1,99), rand(1,29),rand(1,99), rand(1,29),$linecolor);
}
header('Content-Type: image/jpeg');
imagepng($image);
imagedestroy($image);
?>
注册页面
点击高亮
登录页面
数据库