dongrang9300 2014-05-18 06:35
浏览 26

在PHP中显示空白页,而不是重定向

I don't know where I am wrong with this PHP code. When i click on log in in my log in Page the username and password gonna check in this code den it should redirect to 'dashboard.php' but the process gets end on this page. It shows blank. Please can anyone tell me where I am doing wrong?


<?php
include('db.php');
flush();
//error_reporting(1);
$username=$_POST['username'];
$password=sha1($_POST['password']);
$username = stripslashes($username);
$password = stripslashes($password);


$sql="SELECT * FROM user_qc WHERE qc_user_name='$username' and qc_pass='$password'";
$result=mysql_query($sql);

$count=mysql_num_rows($result);

if($count==1){
session_start();
$_SESSION['log'] = 'in';
$_SESSION['username']= $username;
header("Location:dashboard.php");
}
?>

  • 写回答

2条回答 默认 最新

  • dongluan1743 2014-05-18 06:47
    关注

    PHP Variables should be used in double quotes("") while using inside MySQL query.

    <?php
    include('db.php');
    flush();
    //error_reporting(1);
    $username=$_POST['username'];
    $password=sha1($_POST['password']);
    $username = stripslashes($username);
    $username = mysqli_real_escape_string($username);
    $password = stripslashes($password);
    $password = mysqli_real_escape_string($password);
    
    
    $sql="SELECT * FROM user_qc WHERE qc_user_name='".$username."' AND qc_pass='".$password."'";
    $result=mysqli_query($connection, $sql);
    
    $count=mysqli_num_rows($result);
    
    if($count==1){
    session_start();
    $_SESSION['log'] = 'in';
    $_SESSION['username']= $username;
    header("Location:dashboard.php");
    }
    ?>
    

    Don't use mysql rather use mysqli or PDO

    评论

报告相同问题?

悬赏问题

  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大