php code not redirecting me to page

This question already has an answer here:

  • How to make a redirect in PHP? 27 answers

  • You can't set headers with header(...) after any html. You can work around this problem with output buffering. Try adding the following to the top of login.php (that is before your doctype declaration)

    <?php
    ob_start();
    ?>
    

    http://php.net/manual/en/function.ob-start.php


    You have to send the header("Location: member.php") before any other output. So first check if the user has to be redirected (and do so if yes) and then output everything from <!doctype html> on.


    You can try this.

    if($user == $dbusername && $pass == $dbpassword) 
    {
        session_start();
        $_SESSION['sess_user']=$user;
        echo "<script language='javascript'> window.location='member.php'; </script>";
    }
    

    member.php

    if(!isset($_SESSION["sess_user"])) {
        echo "<script language='javascript'> window.location='login.php'; </script>";
    } 
    
    链接地址: http://www.djcxy.com/p/34724.html

    上一篇: 在Bash中重定向stderr和stdout

    下一篇: php代码不会将我重定向到页面