为什么标题功能不能正常工作?

时间:2021-04-25 08:40:13

标签: php html

我正在做一个项目,我想制作一个本地网页。它是用 PHP 制作的这个网站。但我有一些问题。在登录部分输入电子邮件和密码后,代码必须重定向到站点的主页,但它不会这样做。我提到网站的每个页面都组织在一个文件夹中。比如下面是一些文件夹:Main、Login、Register等。我把代码贴在下面看看重定向功能有什么问题。

Mineral-World/Main/Main.php

<html>
    <link rel="stylesheet" href="designMain.css">
    <head>
        
        <link rel="icon" href="/Mineral-World/Main/More/icon.png" >
        <title>Mineral-World</title>

    </head>

    <body>
    
    <div class="topnav">
        <a href="/Mineral-World/Main/Main.php">Home</a>
        <a href="/Mineral-World/Buy/Buy.php">Buy</a>
        <a href="/Mineral-World/Sell/Sell.php">Sell</a>
        <a href="/Mineral-World/Information/Information.php">Information about minerals</a>
        <a style="margin-left:750px;" href="/Mineral-World/Register/Register.php">Register</a>
        <a href="/Mineral-World/Login/Login.php">Login</a>
    </div>

    

    <div class="stylename"> Welcome </div>

    <div class="stylename3" >
        <div class="card1" style="margin-left: 20px;float:left;">
            <div class="stylename1" style="margin-left: 50px;"> What is Mineral-World?</div>
            <div class="stylename2" style="margin-left:15px;"> We are an online market and here you can buy or sell minerals. You will find the best offers!</div>
        </div>
        <div class="card1" style="float:right;">
            <div class="stylename1" style="margin-left: 50px;"> Are any taxes to be paid?</div>
            <div class="stylename2" style="margin-left:15px;"> You can sell or buy minerals without any cost, including the registering process.</div>
        </div>
    </div>

    </body>

</html>

Mineral-World/Login/sessionLogin.php

<?php

    include("ConnectBD_Login.php");
    session_start();
    if(isset($_POST['email'])&&isset($_POST['password']))
    {
        $email=$_POST['email'];
        $pass=md5($_POST['password']);
        $sel="select user from users where email='$email' and pass='$pass'";
        $que=mysql_query($sel);
        if(mysql_num_rows($que)==1)
        {
            $rez=mysql_fetch_row($que);
            $_SESSION['user']=$rez[0];
            header("Location: D:\EasyPHP-5.3.8.1\www\Mineral-World\Main\Main.php");
            exit();
        }
        else{
            $_SESSION['neconect']="Email or password is incorrect!";
            header();
            exit();
        }
    }else {
        $_SESSION['neconect']="Email or password is incorrect!";
        header();
        exit();
    }
    mysql_close();
?>

1 个答案:

答案 0 :(得分:0)

您的标头位置必须是 url 而不是文件路径,试试这个:

header("Location: ../../Main/Main.php");
相关问题