When running on my webserver (hosted via https://www.asurahosting.com/) I get error 500 after logging in. When running on my localhost server (XAMPP on my computer) it runs fine.
My HTML login file
<code><!DOCTYPE html>
<html>
<head>
<title>login Page</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
</head>
<style>
body {
background-image: url('color-splash-background-1920-x-1080-d9zx30h2ybgh18zq.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}
</style>
<body>
<div class="container vh-100">
<div class="row justify-content-center h-100">
<div class="card w-25 my-auto shadow">
<div class="card-header text-center bg-primary text-white">
<h2>Login</h2>
</div>
<div class="card-body">
<form action="index.php" method="post">
<div class="form-group">
<label for="email">Email</label>
<input type="email" id="email" class="form-control" name="email" />
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" id="password" class="form-control" name="password" />
</div>
<input type="submit" class="btn btn-primary w-100" value="Login" name="">
</form>
</div>
<div class="card-footer text-right">
<small>© Liam Adams</small>
</div>
</div>
</div>
</div>
</body>
</html>
</code>
<code><!DOCTYPE html>
<html>
<head>
<title>login Page</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
</head>
<style>
body {
background-image: url('color-splash-background-1920-x-1080-d9zx30h2ybgh18zq.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}
</style>
<body>
<div class="container vh-100">
<div class="row justify-content-center h-100">
<div class="card w-25 my-auto shadow">
<div class="card-header text-center bg-primary text-white">
<h2>Login</h2>
</div>
<div class="card-body">
<form action="index.php" method="post">
<div class="form-group">
<label for="email">Email</label>
<input type="email" id="email" class="form-control" name="email" />
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" id="password" class="form-control" name="password" />
</div>
<input type="submit" class="btn btn-primary w-100" value="Login" name="">
</form>
</div>
<div class="card-footer text-right">
<small>© Liam Adams</small>
</div>
</div>
</div>
</div>
</body>
</html>
</code>
<!DOCTYPE html>
<html>
<head>
<title>login Page</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
</head>
<style>
body {
background-image: url('color-splash-background-1920-x-1080-d9zx30h2ybgh18zq.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}
</style>
<body>
<div class="container vh-100">
<div class="row justify-content-center h-100">
<div class="card w-25 my-auto shadow">
<div class="card-header text-center bg-primary text-white">
<h2>Login</h2>
</div>
<div class="card-body">
<form action="index.php" method="post">
<div class="form-group">
<label for="email">Email</label>
<input type="email" id="email" class="form-control" name="email" />
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" id="password" class="form-control" name="password" />
</div>
<input type="submit" class="btn btn-primary w-100" value="Login" name="">
</form>
</div>
<div class="card-footer text-right">
<small>© Liam Adams</small>
</div>
</div>
</div>
</div>
</body>
</html>
My index.php file:
<code><?php
$email = $_POST['email'];
$password = $_POST['password'];
// database connection
$con = new mysqli("localhost", "", "", "login");
if($con->connect_error){
die("Failoed to connect : " .$con->connect_error);
} else{
$stmt = $con->prepare("select * from reg where email = ?");
$stmt->bind_param("s", $email);
$stmt->execute();
$stmt_result = $stmt->get_result();
if($stmt_result->num_rows > 0) {
$data = $stmt_result->fetch_assoc();
if($data['password'] == $password){
echo "You are now logged into the system";
} else {
echo "Sorry, Wrong password";
}
} else {
echo "<h2> Invalid email or password</h2>";
}
}
?>
</code>
<code><?php
$email = $_POST['email'];
$password = $_POST['password'];
// database connection
$con = new mysqli("localhost", "", "", "login");
if($con->connect_error){
die("Failoed to connect : " .$con->connect_error);
} else{
$stmt = $con->prepare("select * from reg where email = ?");
$stmt->bind_param("s", $email);
$stmt->execute();
$stmt_result = $stmt->get_result();
if($stmt_result->num_rows > 0) {
$data = $stmt_result->fetch_assoc();
if($data['password'] == $password){
echo "You are now logged into the system";
} else {
echo "Sorry, Wrong password";
}
} else {
echo "<h2> Invalid email or password</h2>";
}
}
?>
</code>
<?php
$email = $_POST['email'];
$password = $_POST['password'];
// database connection
$con = new mysqli("localhost", "", "", "login");
if($con->connect_error){
die("Failoed to connect : " .$con->connect_error);
} else{
$stmt = $con->prepare("select * from reg where email = ?");
$stmt->bind_param("s", $email);
$stmt->execute();
$stmt_result = $stmt->get_result();
if($stmt_result->num_rows > 0) {
$data = $stmt_result->fetch_assoc();
if($data['password'] == $password){
echo "You are now logged into the system";
} else {
echo "Sorry, Wrong password";
}
} else {
echo "<h2> Invalid email or password</h2>";
}
}
?>
I have just removed the user and pass for the database
I tried re-installing the database but that did not work. I did not know what else to try.