简体   繁体   中英

PHP | 404 Object not Found

i have a problem with my website. it should get a Login/Sign Up website. If i type in my First and Last name, password and so, i click on submit and 404 Object not Found Appears. The Files are in the correct directory... btw, im not using a htaccess file yet so u dont need to ask for it.

sry for my basic english :)

`

if (isset($POST_['submit'])) 
include_once 'dbh.inc.php';

$first = mysqli_real_escape_string($conn, $_POST['first']);
$last = mysqli_real_escape_string($conn, $_POST['last']);
$email = mysqli_real_escape_string($conn, $_POST['email']);
$uid = mysqli_real_escape_string($conn, $_POST['uid']);
$pwd = mysqli_real_escape_string($conn, $_POST['pwd']);

//error handler
//Check for empty fields
if (empty($first) || empty($last) || empty($email) || empty($uid) || empty($pwd)) {
    header("Location: ../signup.php?signup=empty")
    exit();
} else {
    //Check if inputs are valid
    if (!preg_match("/^[a-zA-Z]*$/", $first) || !preg_match("/^[a-zA-Z]*$/", $first) ) {
        header("Location: ../signup.php?signup=invalid")
        exit();
    } else {
        //check if email is valid
        if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
            header("Location: ../signup.php?signup=email")
            exit();
        } else {
            $sql = "SELECT * FROM users WHERE user_id='$uid'";
            $result =  mysqli_query($conn, $sql);
            $resultCheck = mysqli_num_rows($results);

            if ($resultCheck > 0) {
                header("Location: ../signup.php?signup=usernametaken")
                exit();
        } else { 
            //hashing passwords
            $hashedPwd = password_hash($pwd, PASSWORD_DEFAULT);
            //Insert the user into DB
            $sql = "INSER INTO users (user_first, user_last, user_email, user_uid, user_pwd) VALUES ('$first', '$
            last', '$email', '$uid', '$hashedPwd');";
        $result = mysqli_query($conn, $sql);
        header("Location: ../signup.php?signup=succes")
                exit();
        }
    }   
}



} else {
header("Location: ../signup.php")
exit();
}`

As far as I know you can't use '..' notation in header('location:'). Browsers don't understand '..' notation.

You should use either a fully qualified URL or a relative URL:

This question has already been answered on Stack Overflow

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM