register

来源:互联网 发布:大家都用阿里云做什么 编辑:程序博客网 时间:2024/04/30 10:12

register.html

<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Register</title></head><body><h1>用户注册</h1><form method="POST" action="register.php">用 户 名:<input type="text" name="username" maxlength="30" size="30"></br></br>用户密码:<input type="password" name="password1" maxlength="30" size="30"></br></br>确认密码:<input type="password" name="password2" maxlength="30" size="30"></br></br><input type="submit" value="提交"></form></body></html>



register.php

<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Register</title></head><body><?php$username = $_POST['username'];$password1 = $_POST['password1'];$password2 = $_POST['password2'];if(!$password1 || !$username){echo "用户名或密码不能为空,请重新输入!";exit;}if($password1 != $password2){echo "两次密码不一致,请重新输入!";exit;}@ $db = new mysqli('localhost','root','cookie','cookie');if(mysqli_connect_errno()){echo "数据库链接失败,请重试!";exit;}$query = "insert into userinfo values(0,'".$username."','".$password1."')";$result = $db->query($query);if($result){echo "注册成功!<br />";}else{echo "注册失败!";}$db->close();?><a href="login.html">点击登录</a></body></html>


0 0
原创粉丝点击