最近我一直在尝试设置我的第一个登录页面,并且在我的本地主机(XAMPP)上正确设置但是当我将所有内容上传到我的 cpanel(包括将数据库设置到 phpmyadmin)时,每当我去我的索引(.php)并单击我的登录页面(login.php)它会在空白页面上返回此错误:“无法连接!”这是我的“login.php”文件的内容,如果有帮助的话。任何帮助表示赞赏! |编辑:错误发生在我的网站“https://nexium.cc”上,我使用的是 namecheap 托管 :)
错误发生在此页面上:来自主页的“https://nexium.cc/login.php”:“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>```