Edited: The question that the moderator flagged as 'Already Answered' did NOT answer this question. However, Chris Haas did.
I keep getting the error on line 39 that I do not have a valid username or password, but I am not sure where I am missing the proper logic. Any assistance would be appreciated.
<?php
$configs = include('../hidden/config.php');
echo 'Hello from jslogin.php';
if(isset($_POST)){
/* Login values from user */
$username = $_POST['username'];
$password = password_hash($_POST['password'], PASSWORD_DEFAULT);
/* Define DB variables */
$db_host = $configs['db_host'];
$db_user = $configs['db_user'];
$db_password = $configs['db_password'];
$db_name = $configs['db_name'];
/* Connect to DB */
$dbc = new mysqli($db_host, $db_user, $db_password, $db_name)
or die('Error connecting to Database.');
/* Prepare and bind the statements */
$stmt = $dbc->prepare("SELECT first_name FROM user_reg where username=? AND password=?");
$stmt->bind_param("ss", $username, $password);
/* Execute prepared statements and interpolate parameterized values*/
$stmt->execute();
/* Get result and number of rows returned */
$result = $stmt->get_result();
$count = $result->num_rows;
/* Check to see if statement returned 1 row and pass/fail accordingly and grab firstname*/
if($count == 1){
$firstname = $result;
alert("$firstname Successfully Logged In.");
}else
{
echo 'You need to enter a valid username and/or password!!!';
}
}