I had built a login system (with registration function) and tested it on my server (separate computer on same network) and it all worked fine.
Then I copied the code to my main computer to use it on localhost. Apache server and MySQL server was done throught XAMPP.
When entering the credentials and clicking submit, chrome answers with a HTTP 405 error: HTTP Method not allowed. It seems to be a problem with the method in the form, POST, but I have no clue what. I have checked the apache error log in XAMPP but without success. Nothing had been logged at the time of problem occurence
HTML (only the form part with no CSS):
Login
PHP (The authenticate.php file):
prepare('SELECT id, password FROM accounts WHERE username = ?')){
$stmt->bind_param('s', $_POST['username']);
$stmt->execute();
$stmt->store_result();
}
if ($stmt->num_rows > 0) {
$stmt->bind_result($id, $password);
$stmt->fetch();
if (password_verify($_POST['password'], $password)) {
session_regenerate_id();
$_SESSION['loggedin'] = TRUE;
$_SESSION['name'] = $_POST['username'];
$_SESSION['id'] = $id;
header('Location: home.php');
} else {
echo 'Incorrect password!.';
}
} else {
echo 'Incorrect username and/or password!';
}
$stmt->close();
?>