您的位置:首页技术文章
文章详情页

为什么会注册失败?

【字号: 日期:2022-06-06 18:30:49浏览:65作者:猪猪

问题描述

//连接库$link = new mysqli('localhost', 'root', 'root', 'login');if (!$link) { die("连接失败: " . mysqli_connect_error());}$result = $link -> query("SELECT user FROM log WHERE user = "."'$user'");$rs = $result -> fetch_row();if (!empty($rs)) {echo "<script>alert('用户已存在!');location.href='../login.html';</script>";} else {$link = new mysqli('localhost', 'root', 'root', 'login');$sql="insert into log(user,pwd,sex,age) values('$user','$pwd','$sex','$age')";$rs = mysqli_query($link,$sql);if (!$rs) {echo "<script>alert('注册失败!');location.href='../login.html';</script>";} else {echo "<script>alert('注册成功!返回登录页面');location.href='../index.html';</script>";}}

为什么会注册失败?

数据库也没有写进去数据

问题解答

回答1:打印出sql语句,在mysql工具里面试
相关文章: