I’m having trouble with my custom authentication system after adding WordPress integration. My site has a basic user login where people type their username and password, then click submit to send the data to a PHP script that validates against the database. Everything works perfectly on its own.
The problem starts when I include the WordPress header file to show recent blog posts from my WordPress installation in the same directory. As soon as I add include('wordpress/wp-blog-header.php'), my login stops working and throws database connection errors saying the database credentials are invalid.
Here’s my authentication form code:
if(!isset($_SESSION['user_status']) || $_SESSION['user_status'] == NULL) {
$loginForm = "<h1>User Authentication <small style='color:#E54FBF'>please enter login details</small></h1>
<p>
<label for='userid'>User ID: </label>
<input type='text' name='userid' required />
</p>
<p>
<label for='userpass'>Password: </label>
<input type='password' name='userpass' required />
</p>
<p>
<input type='submit' id='loginBtn' value='Sign In' name='loginBtn' />
</p>";
}
And the submission handler:
if($_POST && !empty($_POST['userid']) && !empty($_POST['userpass'])) {
$result = $userAuth->check_credentials($_POST['userid'], $_POST['userpass']);
}
The strange part is that the error mentions wrong database credentials for the connection itself, not the user input. I double checked my database settings and they’re correct. It seems like WordPress is somehow interfering with my database connection. Has anyone experienced similar issues when mixing custom PHP with WordPress includes?