Php 检查表单中的登录,然后重定向到另一个页面

Php 检查表单中的登录,然后重定向到另一个页面,php,mysql,Php,Mysql,这是我最后一次尝试,也是我最后一次尝试: index.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta conten

这是我最后一次尝试,也是我最后一次尝试:

index.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

    <head>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
        <title>Customer Login</title>
        <link href="stylesheet.css" rel="stylesheet" type="text/css" />
    </head>

    <body>
        <div class="wrapper">
            <div class="login">
                <form name="loginForm" action="loginCheck.php" method="post">
                    <?php require("protect/serverInfo.php"); ?>
                        Email: <input type="text" name="Email" maxlength="35" /><br />
                        Password: <input type="text" name="Password" maxlength="4" /><br />
                    <input type="submit" name ="submit"/>
                </form>
            </div>
        </div>
    </body>

</html>

客户登录
电子邮件:
密码:
loginCheck.php

<?php
        session_start();
        $_SESSION['email'] = $_POST['Email'];
        $_SESSION['password'] = $_POST['Password'];
        require("protect/serverInfo.php");
        $myusername=$_POST[Email]; 
        $mypassword=$_POST[Password];
        $result = mysql_query("SELECT * FROM Customers WHERE Email='$myusername' AND Password=$mypassword");
        $count=mysql_num_rows($result);
        if($count==1){      
            header('Location: customer.php');
            exit();
        }
        else{
            header('Location: index.php');
            exit();
        }
?>

customer.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
<?php
    session_start();
    $myusername = $_SESSION['email']; 
    $mypassword = $_SESSION['password'];
?>
</head>

<body>
<?php
echo"success";
?>

</body>

</html>

无标题1
我只需要一个非常简单的方式来有一个表单张贴,张贴信息要检查是否正确,然后重定向,如果正确,并传递后的数据与它。我一直在尝试使用会话和重定向,但效果不太好。最简单的方法是什么。目前,我一直在使用PHP检查MySQL数据库中的登录信息

在页面上执行任何其他操作之前,需要使用“session_start()”

除此之外,我避免在页面上存储密码。。这似乎是一个安全问题

您的登录表单应该基于从queury返回的mysql信息而不是用户提交的表单信息生成$\u会话数据。您需要对照客户数据库进行检查,以确保他们是实际客户

另外,避免使用“header()”函数,尤其是在处理会话时。我通常在php中有一个“重定向”函数,它可以执行以下操作

function redirect($url) { 
    echo "<script type='text'/javascript'>window.location='" . $url . "';</script>";
}
函数重定向($url){

回音"你能发布不太正常的代码吗?我发布了我的代码。我知道位置不再是正确的URL,我只是更改了它,这样URL就不再显示了。页面一直到客户页面,然后就不再加载。是的。如果你还没有收到与此相关的错误,可能是你有php错误报告f、 只需知道,在生成页面上的任何标题/内容类型之前,必须先启动会话。好的,我正在更新我的代码,我会记住你告诉我的事情。我似乎仍然对会话加载有问题。我甚至刚刚测试了使会话$\u会话['email']=“你好”;传递它并试图回应它,但它似乎什么也装不下。