I received an error message saying from a login page in created using xampp and php as my code. "This page isn’t working right now If the problem continues contact the site owner. HTTP ERROR 405" when I try logging in to the page,
I expect it to open another page saying "login success or failed to login" it was working at first but after I transferred the login page from git hub to my vsCode to make some few modifications, it wasn't working anymore. I don't know if the problem is from my codes or its from my server. if its from my codes, how do I fix it and if its from my server how do I fix it also.
this is my html code:
<!-- Login form Code -->
<form action="POST" class="clearfix form-hidden" id="Register-form">
<h1>Register</h1>
<div class="col-md-12">
<div class="input-group blmd-form">
<div class="blmd-line">
<input type="text" name="username" autocomplete="off" id="username" class="form-control">
<label class="blmd-label">Email or Username</label>
</div>
</div>
<div class="input-group blmd-form">
<div class="blmd-line">
<input type="password" name="password" autocomplete="off" id="password" class="form-control">
<label class="blmd-label">Password</label>
</div>
</div>
<div class="input-group blmd-form">
<div class="blmd-line">
<input type="password" name="rePassword" autocomplet
e="off" id="password" class="form-control">
<label class="blmd-label">Repeat Password</label>
</div>
</div>
</div>
<div class="col-sm-12 text-center">
<button type="button" class="btn btn-blmd ripple-effect btn-warning btn-lg btn-block">Register</button>
</div>
<br/>
</form>`
here is the php code for the login aspect
<?php
if($_SERVER["REQUEST_METHOD"] == "POST"){
//retrieve from data
$username = $_POST['username'];
$password = $_POST['password'];
//database connection
$host = "localhost";
$dbusername = "root";
$dbpassword = "";
$dbname = "auth0";
$conn = new mysqli($host, $dbusername, $dbpassword, $dbname);
if($conn->connect_error){
die("connection failed: ". $conn->connect_error);
}
//validate login authentication
$query = "SELECT * FROM login WHERE username='$username' AND password='$password'";
$result = $conn->query($query);
if($result->num_rows == 1){
//login success
header("location:success.html");
exit();
}
else{
//login failed
header("location:error.html");
exit();
}
// if (!$result) {
// die("Query failed: " . $conn->error);
// }
//$conn->close();
}
?>
below are the html codes for the pages i want to be redirected to when i successfully or unsuccessfully login:
success page
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Success</title>
</head>
<body>
<h1>Success</h1>
</body>
</html>
error page
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Error</title>
</head>
<body>
<h1>Failed to login</h1>
</body>
</html>
I tried to uninstall my xampp and reinstalled it again using the same setup. so I expected it to fix the issue since I thought my site will have a fresh database in the localhost admin.
source https://stackoverflow.com/questions/77508270/this-page-isn-t-working-right-now-if-the-problem-continues-contact-the-site-owne
No comments:
Post a Comment