为什么我的表单没有提交POST值?

时间:2017-01-26 17:37:22

标签: php forms

我正在创建这个处理登录和注册请求的简单页面,但出于某种原因,我的表单没有提交我的一个帖子值。

PHP

session_start();

$ip = $_SERVER['REMOTE_ADDR'];

if(isset($_SESSION["sid"])) {
    $sid = $_SESSION["sid"];

} else {
    if(isset($_GET['login'])){
        $code = MySQLConnection::login($_POST['email'], $_POST['password'], $ip);
        /**
         * Login Error codes
         * ______________________________________________
         * |   0    |        EVERY THING IS OK          |
         * |--------+-----------------------------------|
         * |   1    |          No Such User             |
         * |--------+-----------------------------------|
         * |   2    |         Incorrect Pass            |
         * |--------+-----------------------------------|
         * |   3    |        Error Signing in           |
         * |--------------------------------------------|
         */
        switch($code) {
            case 0:
                header("Location: ControlCenter.php");
                break;
            case 1:
            case 2:
                header("Location: index.html?error=1");
                break;
            case 3:
                header("Location: index.html?error=2");
                break;
        }
    } else if(isset($_GET['register'])){
        if(isset($_POST['email'])) {
            MySQLConnection::register($_POST['email']);
            echo("success");
        } else {
            echo("Email not submitted");
        }
    }
}

HTML

<form method="post" action="authenticator3000.php?register">
    <input type="text" name="email" class="email" placeholder="email" required="required"/>
    <input type="submit" value="register" />
</form>

错误发生在注册功能之前,因为在运行时,&#34;电子邮件未提交&#34;是回声&#d; d。

没有if语句检查POST是否设置我得到:

Notice: Undefined index: email

我不确定我的问题在哪里,因为电子邮件的价值将通过method =&#34; get&#34;提交。我在页面中有另一个用于登录用户的表单,一切都在那里提交。

用于登录的HTML:

<form action="authenticator3000.php?login" method="post">
    <input type="text" name="email" class="email" placeholder="email" required="required"/>
    <input type="password" name="password" class="password" placeholder="password" required="required"/>
    <input type="submit" value="login" />
</form>

每个值都会提交并正常运行。我甚至重新复制并粘贴了我的代码,从登录到注册区域,并将?login更改为?注册。

据我所知,没有语法错误。

更新

我刚刚在登录部分测试了var_dump,发现$ _POST也是空的。

1 个答案:

答案 0 :(得分:0)

我的服务器配置错误。我不确定为什么,但我使用了不同的服务器,一切正常。谢谢你的帮助

相关问题