目前,我正在使用000webhost来构建我的网站。我还在000Webhost免费托管中配置Wordpress。目前,我的问题是当我尝试登录时,它会显示消息
Failed to query database Access denied for user 'id1351040_wp_f95ca011d778539df40db16f9d312e34'@'%' to database 'login_table'
根据我的Wordpress页面,我创建了表单,编码将显示在下面
<form id="form1" name="form1" method="post" action="../wp-content/themes/main/process.php" onsubmit="return check();">
根据Phpmyadmin,这是目录 /public_html/wp-content/themes/main/process.php让表单动作将它链接到这里。 process.php的代码如下所示:
<?php
error_reporting(E_ALL & ~E_NOTICE);
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
// connect to the server and select database
$con = mysqli_connect("localhost", "id1351040_wp_f95ca011d778539df40db16f9d312e34", "xxxxxx", "id1351040_wp_f95ca011d778539df40db16f9d312e34");
mysqli_select_db($con,"login_table") or die(mysqli_error($con));
// Get values passe from form in login.php file
$username = $_POST['user'];
$password = $_POST['pass'];
// to prevent mysql injection
$username = stripcslashes($username);
$password = stripcslashes($password);
$username = mysqli_real_escape_string($con, $username);
$password = mysqli_real_escape_string($con, $password);
// Query the database for user
$result = mysqli_query($con, "select * from login where ID = '$username' and Password = '$password'")
or die("Failed to query database ".mysqli_error($con));
$row = mysqli_fetch_array($con, $result);
session_start();
if($row['ID'] == $username && $row['Password'] == $password ){
header( 'Location: https://xxxxxx/' ) ;
}
else{
echo "Failed to login!";
}
?>
phpmyadmin的屏幕截图 Screenshot of Phpmyadmin 这是结果 Result