diff --git a/课堂代码/01-blog开发/v1/README.md b/课堂代码/01-blog开发/v1/README.md new file mode 100644 index 0000000..50c0181 --- /dev/null +++ b/课堂代码/01-blog开发/v1/README.md @@ -0,0 +1,4 @@ +# v1版本更新说明 + +- 实现了登录注册功能 +- SQL注入问题完全没解决 \ No newline at end of file diff --git a/课堂代码/01-blog开发/v1/login.html b/课堂代码/01-blog开发/v1/login.html new file mode 100644 index 0000000..a860264 --- /dev/null +++ b/课堂代码/01-blog开发/v1/login.html @@ -0,0 +1,415 @@ + + + + + + + 欢迎登录 + + + + + +
+
+
+ +
+
+

欢迎登录

+

请输入您的账号信息

+
+ +
+ + +
+ + 👤 +
+ +
+ + 🔒 +
+ +
+ + 忘记密码? +
+ + +
+ + + +
+ + + \ No newline at end of file diff --git a/课堂代码/01-blog开发/v1/register.html b/课堂代码/01-blog开发/v1/register.html new file mode 100644 index 0000000..8967845 --- /dev/null +++ b/课堂代码/01-blog开发/v1/register.html @@ -0,0 +1,416 @@ + + + + + + + 欢迎注册 + + + + + +
+
+
+ +
+
+

欢迎注册

+

请创建您的账号信息

+
+ +
+ + +
+ + 👤 +
+ +
+ + 🔒 +
+ +
+ + 🔒 +
+ +
+ + 📧 +
+ + +
+ + + +
+ + + \ No newline at end of file diff --git a/课堂代码/01-blog开发/v1/users.php b/课堂代码/01-blog开发/v1/users.php new file mode 100644 index 0000000..b71aeee --- /dev/null +++ b/课堂代码/01-blog开发/v1/users.php @@ -0,0 +1,98 @@ + 0) { + echo "登录成功"; + }else{ + echo "用户名或密码错误"; + } + +}else if(isset($_REQUEST["register"])){ + // 从前端获取用户名,以及两次密码输入,以及邮箱 + $username = $_REQUEST["username"]; + $password = $_REQUEST["password"]; + $password2 = $_REQUEST["password2"]; + $email = $_REQUEST["email"]; + + // 判断两次密码是否一致 + if ($password != $password2) { + echo "两次密码不一致"; + exit; + } + + // 判断用户名或邮箱是否已存在 + $sql = "select * from users where username='$username' or email='$email'"; + $result = mysqli_query($conn, $sql); + if (mysqli_num_rows($result) > 0) { + echo "用户名或邮箱已存在"; + exit; + } + + // 写sql语句,插入一条新的用户记录 + $sql = "insert into users(username, password, email) values('$username', '$password', '$email')"; + $result = mysqli_query($conn, $sql); + + // 插入成功后,返回注册成功信息 + if ($result) { + echo "注册成功"; + } else { + echo "注册失败"; + } + +}else{ + echo "错误操作"; +} + + + + + +// // 从前端获取用户名和密码 +// $username = $_REQUEST["username"]; +// $password = $_REQUEST["password"]; + + + + +// // 查询数据库中的users表,并且将$username和$password作为条件查询 +// $sql = "select * from users where username='$username' and password='$password'"; +// $result = mysqli_query($conn, $sql); +// if (!$result) { +// echo "查询失败"; +// exit; +// } + +// // 如果查询结果为空,则提示用户名或密码错误 +// if (mysqli_num_rows($result) == 0) { +// echo "用户名或密码错误 返回登录页面"; +// exit; +// }else{ +// echo "登录成功"; +// } + +?> \ No newline at end of file diff --git a/课堂代码/01-blog开发/v1/数据库截图.png b/课堂代码/01-blog开发/v1/数据库截图.png new file mode 100644 index 0000000..dc21ba6 Binary files /dev/null and b/课堂代码/01-blog开发/v1/数据库截图.png differ