PHP login system works on local but doesn't work on Hostgator PHP 7.1. My local is PHP 7.2
I've built out a fully working portal on my local machine. I can CRUD on my local machine. As soon as I put it on the server online, the login system doesn't work. I still can register new users as the user info populates in the DB, so its not a DB config issue. I am getting these errors:
Warning: mysqli_stmt_bind_param(): Number of variables doesn't match number of parameters in prepared statement in .....
Fatal error: Uncaught Error: Call to undefined function mysqli_stmt_get_result() in ....
I have spent 5 hours trying to figure out why it won't work on the Hostgator server but will work on my local.
Here is my code:
if(isset($_POST['loginSubmit'])){
//include connection configs
require '../../db_configs.php';
$email = mysqli_real_escape_string($conn, $_POST['email']);
$password = mysqli_real_escape_string($conn, $_POST['password']);
if(empty($email || $password )){
header("Location: ../../../portalSignIn.php?signin=fieldsempty");
exit();
}
else
{
//user email query
$sqlEmail = "SELECT * FROM users WHERE email='$email'";
$emailResult = mysqli_query($conn, $sqlEmail);
$stmt = mysqli_stmt_init($conn);
//SQL Error
if(!mysqli_stmt_prepare($stmt, $sqlEmail)){
header("Location: ../../../portalSignIn.php?signin=SQL_FAILED");
exit();
}
if(mysqli_num_rows($emailResult) == 0){
//email doesn't exist
header("Location: ../../../portalSignIn.php?signin=incorrectemail");
exit();
}
else
{
//bind data if email exists
mysqli_stmt_bind_param($stmt, "s", $email);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
if($row = mysqli_fetch_assoc($result)){....
Its breaking at this point --> mysqli_stmt_bind_param($stmt, "s", $email);
I've looked into https://www.plus2net.com/php_tutorial/mysqli_mysqlnd.php and Hostagtor doesn't have these settings. And I have used mysqli_stmt_bind_param() successfully on the sign up page.