dongzhan8001 2019-04-04 17:12 采纳率: 0%
浏览 56

虽然用户名和密码在cpanel中是正确的,但页面不会重定向

I created php web application and it is working in my localhost.In addition to that it was working more than one year in cpanel hosting and i change domain and hosting provider. Now i am unable to login to my system. it does not show any error. what i can understand is session is not creating properly. when i went dashboard, it will redirect to again same login page.

Because of Session error, i created file which has only session and just if statement. it is working fine.

<?php
session_start();
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        $user_name = (isset($_POST['txt_username']) ? $_POST['txt_username'] : null);
        $password = md5($_POST['txt_password']);
        if (!empty($user_name) && !empty($password)) {
            $sql = "SELECT * FROM user WHERE User_Name='$user_name' && Password='$password'";

        $result = mysqli_query($conn, $sql);

        if ($row = mysqli_num_rows($result) == 1) {
            $_SESSION['username'] = $user_name;
            $_SESSION['password'] = $password;
         //header("location:htdocs/dashbd.php");

           // echo '<script type="text/javascript">';
         //   echo "<script>location='htdocs/dashbd.php'</script>";
           // echo 'alert("User name or Password is Incorrect");';
            echo 'window.location = "htdocs/dashbd.php";';
          //  echo '</script>';
           // } else {
          //      echo"error";
          if(isset($_SESSION['username'])){
              header("location:htdocs/dashbd.php");
          echo 'window.location = "htdocs/dashbd.php";';

    }
            }
        } else {
            echo '<script type="text/javascript">';
            echo 'alert("User name or Password is Incorrect");';
            echo 'window.location = "index.php";';
            echo '</script>';
        }
    } else {
        echo '<script type="text/javascript">';
       // echo 'alert("Username And Password Cannot Be Empty");';
      //  echo'getElementById("#feedback").innerHTML="mukuth nene";';
        //echo 'window.location = "index.php";';
        echo '</script>';
    }

?>

when user name and password is correct it needs to redirect to htdocs/dashboard.php. in current situation wont.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 iqoo11 如何下载安装工程模式
    • ¥15 本题的答案是不是有问题
    • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
    • ¥15 C++使用Gunplot
    • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
    • ¥15 matlab数字图像处理频率域滤波
    • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
    • ¥15 ELGamal和paillier计算效率谁快?
    • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题
    • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?