dongtui8593 2014-11-22 15:02
浏览 32

无法使用我的数据库注册

I need to make a Sign in form for my website. And I have to use MySQLi because MySQL will cause decaprated on my try. So, here's the index.php code:

<?php
session_start();ob_start();

$con=mysqli_connect("localhost","root","","oos");
if (mysqli_connect_errno()) echo "Failed to connect to MySQL: " . mysqli_connect_error();

    if(isset($_POST['signin']))
    {
        $username = $_POST['userid'];
        $pass = $_POST['password'];

        $query1 = "select * from admintb where adID = '$username' and adPass = 'password' ";
        $result1 = mysqli_query($con,$query1) or die;

        $co=0;

        while($row=mysqli_fetch_assoc($result1)) $co++;
        if($co==1)
        {
            $_SESSION['a']=$username;
            header("Location: main_menu.php");
        }
    }   ?>

The problem is, when I make $username="admin" and $password = "admin", it will go to main_menu.php alright. But when I try to do as above, base on my database, it won't go to main_menu.php. How can I sign in, go to the main_menu.php using ID from my database?

  • 写回答

1条回答 默认 最新

  • dsf487787 2014-11-22 15:22
    关注

    Sorry, I already checked it, it's a stupid mistake. Inside this snippet:

     $username = $_POST['userid'];
        $pass = $_POST['password'];
    
        $query1 = "select * from admintb where adID = '$username' and adPass = 'password' ";
        $result1 = mysqli_query($con,$query1) or die;
    

    fix to this:

    $query1 = "select * from admintb where adID = '$username' and adPass = '$pass' ";
    
    评论

报告相同问题?

悬赏问题

  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致