Recently I've been trying to set up my first login page, and I set it up correctly on my localhost (XAMPP) But when I uploaded everything to my cpanel (including setting up a database into phpmyadmin) whenever I go to my index(.php) and click on my login page (login.php) it returns this error on a blank page: "failed to connect!" Here is the contents of my "login.php" file, if that even helps. Any help is appreciated! | EDIT: the error is occurring on my website "https://nexium.cc", I'm using namecheap hosting :)
the error happens on this page: "https://nexium.cc/login.php" from the main page: "https://nexium.cc/index.php"
<?php
session_start();
include("connection.php");
include("functions.php");
if($_SERVER['REQUEST_METHOD'] == "POST")
{
//something was posted
$user_name = $_POST['user_name'];
$password = $_POST['password'];
if(!empty($user_name) && !empty($password) && !is_numeric($user_name))
{
//read from database
$query = "select * from users where user_name = '$user_name' limit 1";
$result = mysqli_query($con, $query);
if($result)
{
if($result && mysqli_num_rows($result) > 0)
{
$user_data = mysqli_fetch_assoc($result);
if($user_data['password'] === $password)
{
$_SESSION['user_id'] = $user_data['user_id'];
header("Location: index.php");
die;
}
}
}
echo "wrong username or password!";
}else
{
echo "wrong username or password!";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Nexium/Login</title>
</head>
<body>
<style type="text/css">
body{
font-family: Monaco, "Lucida Console", monospace;
font-weight: normal;
width: 100;
background-image: url('bg.jpg');
background-repeat: no-repeat;
background-color: black;
background-size: cover;
background-position: center;
min-height: 100vh;
}
.ui-home{
margin-top: 10px;
text-align: center;
list-style-type: none;
font-family: Monaco, "Lucida Console", monospace;
font-weight: normal;
font-style: bold;
margin-left: -35px;
}
.ui-home:hover{
color: #fb00ff;
font-style: bold;
text-transform: uppercase;
text-transform: none;
}
#box {
text-align:center;
padding-top: 390px;
}
.signup-bottom:hover{
color: #551a8b;
}
.signup-bottom{
color: white;
}
#button{
color:#551a8b;
}
#text{
border-radius: 5px;
height:20px;
}
</style>
<div id="box">
<form method="post">
<div style="font-size: 30px;margin: 10px;color: white;">Login</div>
<input id="text" type="text" name="user_name"><br><br>
<input id="text" type="password" name="password"><br><br>
<input id="button" type="submit" value="Login"><br><br>
<a class="signup-bottom" href="signup.php">Click to Signup</a><br><br>
</form>
</div>
</body>
</html>```