首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从登录页重定向登录用户

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

Stack Overflow用户
提问于 2018-02-07 00:40:12
回答 1查看 37关注 0票数 1

环顾四周的其他职位,但仍在挣扎。目前有一个客户关系管理系统正在运行。用户从/index.php开始。

代码语言:javascript
复制
<?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';
?>

因此,/header.php包含:

代码语言:javascript
复制
<?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($_SESSION'u_uid'))标题(“Location:登录时将被重定向到哪里->view.php])

我不知道这句话该怎么说。如果有任何其他语法需要添加。

非常感谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-02-07 03:34:13

如果我正确理解,这段代码将帮助你。

代码语言:javascript
复制
if (isset($_SESSION['u_uid']))
    echo ('<script type="text/javascript">window.location.replace("http://yoursite.com/yourpath.php");</script>');
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48654231

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档