登陆

为什么会注册失败?


//连接库$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>"; }}


为什么会注册失败?

数据库也没有写进去数据

# PHP
零宇塔时℡คิดถึง零宇塔时℡คิดถึง49 天前114 次浏览

全部回复(1)我要回复

  • lk

    lk2020-01-15 18:31:53

    打印出sql语句,在mysql工具里面试

    回复
    0
  • 取消回复发送