How to redirect to another page using PHP

前端 未结 12 1398
粉色の甜心
粉色の甜心 2020-12-02 16:50

I am building a website which includes a login page. I need to redirect the user to their profile page once they\'ve logged in successfully, but I don\'t know how to do that

12条回答
  •  猫巷女王i
    2020-12-02 17:44

    firstly create index.php page and just copy paste below code :-
    
    
    
    
    
    /*------------------after that ----------------------*/
    
    create a login_check.php and just copy paste this below code :-
    
    
    
    
    0)
    {   
    
        $result = mysql_query("SELECT * FROM admin WHERE username='".$_POST["username"]."' and password = '".$_POST["password"]."'");
        $row  = mysql_fetch_array($result);
    
    if(is_array($row)) 
    {
        $_SESSION["user_id"] = $row[user_id];
        $_SESSION["username"] = $row[username];
    
        $session_register["user_id"] = $row[user_id];
        $session_register["username"] = $row[username];
    } 
    else 
    {
       $_SESSION['msg']="Invalid Username or Password";
       header("location:index.php");
    }
    }
    
    if(isset($_SESSION["user_id"]))
    {
        header("Location:dashboard.php");
    }
    
    ?>
    
    
    
    
    /*-----------------------after that ----------------------*/
    
    
    create a dashboard.php and copy paste this code in starting of dashboard.php
    
    
    
    
    
    
    
    
    /*-----------------------after that-----------------*/ 
    
    
    
    create a check_session.php which check your session and copy paste this code :- 
    
    
    
        Welcome . Click here to Logout.
    
    
    
    
    
    
    if you have any query so let me know on my mail id farjicompany@gmail.com
    

提交回复
热议问题