Currently, I’m using the 000webhost to build my website. I also configure WordPress in the 000Webhost free hosting. Currently, my problem is when I try to login, it shows me the message

 Failed to query database Access denied for user 'id1351040_wp_f95ca011d778539df40db16f9d312e34'@'%' to database 'login_table'

Based on my WordPress pages, I created the form and the coding will be shown below

<form id="form1" name="form1" method="post" action="../wp-content/themes/main/process.php" onsubmit="return check();">

According to the Phpmyadmin, this is the directory
/public_html/wp-content/themes/main/process.php which let the form action to link it to here. The code for process.php will be shown as below:

<?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!";
}

?>

The screenshot for phpmyadmin
Screenshot of Phpmyadmin
This is the result of
Result

Read more here: Why I failed to query database?


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: