代码之家  ›  专栏  ›  技术社区  ›  kerry sun

从登录页面重定向登录用户

  •  1
  • kerry sun  · 技术社区  · 8 年前

    环顾其他帖子,但仍在苦苦挣扎。目前正在运行CRM系统。用户在/索引中开始。php。

    <?php
    include_once'header.php';   
    ?>
    
    <section class="main-container">
    <div class="main-wrapper">
        <h2>Motoko</h2>
    
        <?php   
    
            if (isset($_GET["msg"]) && $_GET["msg"] == 'failed') {
            echo "Incorrect Username/Password";
            } 
            else { if (empty($uid) || empty($pwd))
            echo "You are not logged in";
                }                   
        ?>
    </div>
    </section>
    <?php
    include_once 'footer.php';
    ?>
    

    其中/标题。php包含:

    <?php
    session_start();
    ?>
    
    <!DOCTYPE html>
    <html>
    <head>
    <title>Motoko</title>
    <link rel="stylesheet" type="text/css" href="style.css">
    
    </head>
    <body>
    <header> 
    <nav>
        <div class="main-wrapper">
            <ul>
                <li><a href="index.php">Home</a></li>   
            </ul>
            <div class="nav-login">
                <?php
                    if (isset($_SESSION['u_id'])){
                    echo '<form action="includes/logout.inc.php" method="POST">
                    <button type="submit" name="submit">Logout</button>
                    </form>';
                    } else {
                    echo '<form action="includes/login.inc.php" method="POST"> 
                    <input type="text" name="uid" placeholder="Username/e-mail">
                    <input type="password" name="pwd" placeholder="password">
                    <button type="submit" name="submit">Login</button> 
                    </form>';
    
                    echo '<form action="signup.php" method="POST"> 
                    <button type="submit">Sign up</button> 
                    </form>';
    
                    echo '<form action="reset.php" method="POST"> 
                    <button type="submit">Forgot your Password?</button> 
                    </form>';
    
                    }
                ?>
            </div>
        </div>
    </nav>
    </header>
    

    我需要添加一些类似if(isset($\u SESSION['u\u uid]))的标题(“位置:登录时重定向到的位置-->view.php)

    我不知道该怎么说。以及是否需要添加任何其他语法。

    非常感谢!

    1 回复  |  直到 8 年前
        1
  •  1
  •   Onur Uslu    8 年前

    如果我理解正确,此代码将帮助您。

    if (isset($_SESSION['u_uid']))
        echo ('<script type="text/javascript">window.location.replace("http://yoursite.com/yourpath.php");</script>');
    
    推荐文章