PHP 注册表单 post 操作期间出错

PHP error during registration form post action

我一直在尝试编写注册表单,但遇到了一些问题。 我收到的错误是 404 错误,指出引用 link 已过时或不正确。

我很困惑为什么,因为我知道该文件存在于同一目录中并且我已经这样称呼它。

请看下面。如果这还不够,我已经 link 编辑了整个项目 here

据我所知,错误似乎来自我的检查中的引用 link-registration.php,这是我的表单 post 指向的操作:

检查注册php:

<?PHP session_start();

include "../../functions/registration.php";
check_form("Register", "username", $_POST['username']);
check_form("Register", "email", $_POST['email']);
check_form("Register", "password1", $_POST['password1']);
check_form("Register", "password2", $_POST['password2']);

if ($_SESSION['registration-username'] == "OK")
{
    $username = htmlentities($_POST['username']);
    check_exists_username($username);

}

if ($_SESSION['registration-mail'] == "OK")
{
    $email = htmlentities($_POST['email']);
    check_regex_mail($email);
    $return = check_exists_mail($email);
    $_SESSION['flag-email-exists'] = ($return > 0) ? "KO" : "OK";
}

if ($_SESSION['registration-password1'] == "OK")
{
    $password1 = $_POST['password1'];
    check_regex_password($password1, "flag-regex-password");
}

if ($_SESSION['registration-password2'] == "OK")
{
    $password2 = $_POST['password2'];
}
if ($_SESSION['registration-password1'] == "OK" && $_SESSION['registration-password2'] == "OK")
{
    check_same_password($password1, $password2, "same-password");
}

if ($_SESSION['registration-username'] == "OK" && $_SESSION['registration-email'] == "OK"
&& $_SESSION['registration-password1'] == "OK" && $_SESSION['registration-password2'] == "OK"
&& $_SESSION['flag-regex-password'] == "OK" && $_SESSION['flag-regex-mail'] == "OK"
&& $_SESSION['flag-user-exists'] == "OK" && $_SESSION['flag-email-exists'] == "OK"
&& $_SESSION['same-password'] == "OK")
{
    echo $username;

$_SESSION['flag-registration'] = "OK";
try{
    include '../../config/database.php';
    $bdd = new PDO($DB_DSN, $DB_USER, $DB_PASSWORD);
    $bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $bdd->query("USE camagru");
    $password = hash('sha512', $password1);
    $requete = $bdd->prepare("INSERT INTO `utilisateurs` (`login`, `email`, `groupe`, `mdp`)
    VALUES(:username, :email, :user, :password)");
    $requete->bindParam(':username', $username);
    $requete->bindParam(':email', $email);
    $requete->bindValue(':user', 'user');
    $requete->bindParam(':password', $password);
    $requete->execute();

    send_confirmation_mail($username, $email, $_POST['submit']);
}
catch (PDOException $e) {
    print "Error : ".$e->getMessage()."<br/>";
    die();
}
echo "<meta http-equiv='refresh' content='0,url=registration.php'>";

}
else {
    echo "<meta http-equiv='refresh' content='0,url=registration.php'>";
    exit();
}
?>

这是注册页面:

   <?PHP session_start();
        if ($_SESSION['id'])
        {
            header('Location: ../account/my-account.php');
        exit();
    }

?>
<!DOCTYPE html>
<html>
<head>
<style>
    @import url('https://fonts.googleapis.com/css?family=Merienda+One');
    @import url('https://fonts.googleapis.com/css?family=Open+Sans');
</style>
<link rel="stylesheet" type="text/css" href="../../css/global.css">
<link rel="stylesheet" type="text/css" href="../../css/header.css">
<link rel="stylesheet" type="text/css" href="../../css/inscription.css">
<meta name="google" content="notranslate" />
<title>Register - Camagru</title>
</head>

<body>
    <?php
    $current_page = "Register";
    include '../../header.php';
    ?>
    <div class="center">
        <h2>Register</h2><br/>

        <form action="checking-register.php" method="post">
            <fieldset>
                <legend>Register Below</legend><br/>
            <label for="username">Username :</label>
            <input
            type="text"
            name="username" id="username"
            <?PHP if ($_SESSION['registration-username'] == "KO" ||
            $_SESSION['flag-user-exists'] == "KO")
            {echo "class='invalid'";}?>><br/><br/>
            <label for="email">Email :</label>
            <input
            type="email"
            name="email"
            id="email"
            <?PHP if ($_SESSION['registration-mail'] == "KO" ||
            $_SESSION['flag-regex-mail'] == "KO" || $_SESSION['flag-email-exists'] == "KO")
            {echo "class='invalid'";}?>><br/><br/>
            <label for="password1">Password :</label>
            <input
            type="password"
            name="password1"
            id="password1"
            <?PHP if ($_SESSION['registration-password1'] == "KO" ||
            $_SESSION['flag-regex-password'] == "KO")
            {echo "class='invalid'";}?>><br/><br/>
            <label for="password2">Repeat Password :</label>
            <input
            type="password"
            name="password2"
            id="password2"
            <?PHP if ($_SESSION['registration-password2'] == "KO")
            {echo "class='invalid'";}?>><br/><br/>
            <input
            type="submit"
            name="submit"
            value="Submit"/>
        </fieldset>
        </form><br/><br/>

        <?PHP
        include "../../errors.php";
        error_registration();
        delete_error_registration();
        ?>
    </div>
</body>
<?php
include '../../footer.php';
 ?>


</html>

修正你的 link:

echo "<meta http-equiv='refresh' content='0,url=registration.php'>";

echo "<meta http-equiv='refresh' content='0,url=register.php'>";

PS:您可以使用 php 和

进行重定向
header('Location: register.php');