dougou7008 2015-11-27 10:22
浏览 36

PHP:登录系统不能在现实世界中工作但在WAMP / MAMP中工作正常:(

I just finished building the first website in my life! Everything works fine in my MAMP/WAMP. So excited but when I am testing it in real environment today with hosting software C-Panel, but it turns out my login page doesn't work. The website does nothing when user submit the form where the user should be redirected to main.php.

My face turns from :) into :( just now. Below is my login.php, could anyone help to point out what might be the problem?

<?php if(!SESSION_id()) SESSION_start();?>
<html>
<head><title>login with your account</title></head>
<body>
    <form action="login.php" method="POST">
    <input type="text" name="email" placeholder="Email">
    <br>
    <input type="password" name="password" placeholder="Password">
    <br>
    <input type="submit" value="Log in" name="submit">
    </form>
</body>
</html>

<?php

require ("connect.php");



//declair the variable
$email=@$_POST["email"];
$password=@$_POST["password"];
//encrypt the password
$psw_en=sha1($password);

if(isset($_POST["submit"])){

    if($email || $password){
        if($email){
            if($password){ 
                $sql="select * from users where email='$email'";

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

                    if ($check_rows !=0){
                         while ($row=mysqli_fetch_assoc($result)){
                            $db_email=$row["email"];
                            $db_psw_en=$row["password"];
                            $db_full_name=$row["full_name"];
                            $db_id=$row["user_id"];
                            $db_topics=$row["topics"];
                            $db_date_of_registration=$row["date_of_registration"];
                            $db_pic=$row["pic"];
                         }

                         if($email==$db_email&&$db_psw_en==$psw_en){
                            $_SESSION["id"] = $db_id;
                            $_SESSION["email"] = $email;
                            $_SESSION["full_name"] = $db_full_name;
                            $_SESSION["topics"] = $db_topics;
                            $_SESSION["date_of_registration"] = $db_date_of_registration;
                            $_SESSION["pic"] = $db_pic;
                            $_SESSION["password"] = $db_password;


                            header("Location: main.php");


                         }
                         else{
                            echo "password is wrong";
                         }

                    }
                    else {
                        echo "you are not registered,yet. Click here to <a href=\"register.php\">register</a>";
                    }

            }
            else{
                echo "it looks like password is empty";
            }
        }
        else{
            echo "it looks like email is empty";
        }
    }
    else{
        echo "it looks like everything is empty";
    }
}







?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
    • ¥20 西门子S7-Graph,S7-300,梯形图
    • ¥50 用易语言http 访问不了网页
    • ¥50 safari浏览器fetch提交数据后数据丢失问题
    • ¥15 matlab不知道怎么改,求解答!!
    • ¥15 永磁直线电机的电流环pi调不出来
    • ¥15 用stata实现聚类的代码
    • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
    • ¥20 docker里部署springboot项目,访问不到扬声器
    • ¥15 netty整合springboot之后自动重连失效