前端页面可使用了bootstrap框架,直接引用了网页链接
- 前端注册页面(一开始只用于测试,后期的页面将在最后的完成项目发出)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>
测试项目
</title>
</head>
<body>
<form action="./action.php" method="POST">
用户名:<input name="username" type="text" id="username">
密码:<input name="password" type="password" id="password">
邮箱:<input name="email" type="text" id="email">
<input type="submit" value="提交" name="submit">
</form>
</body>
</html>
- 数据库连接
<?php
$connect = mysqli_connect("localhost","root","","php1-1");
if(!$connect){
die("数据库连接失败!");
}
?>
3.注册页面用于接收表单的数据,并且插入到数据库里面
<?php
$username = isset($_POST['username'])?$_POST['username']:"";
$password = isset($_POST['password'])?$_POST['password']:"";
$email = isset($_POST['email'])?$_POST['email']:"";
if(isset($_POST['submit'])){
include("./connect.php");
$sql_insert = "insert into userres(username,password,email) values ('$username','$password','$email')";
$res = mysqli_query($connect,$sql_insert);
if($res){
echo "恭喜你,添加数据成功!";
}
}
mysqli_close($connect);
?>
注:头标签可以先不写,因为是后面的半成品的信息提示!
数据库设计根据代码设计,也可以进行改动,此时数据插入就已经完成。
接下来就是用户登录。