0

Hello i have a problem with following code on my website:

<?php
session_start();
include '../databaseConnector.php';

$uid = mysqli_real_escape_string($connector, $_POST['uid']);
$pwd = mysqli_real_escape_string($connector, $_POST['pwd']);


$stmt = $connector->prepare("SELECT * FROM nutzer WHERE uid=?");
$stmt->bind_param("s", $username);

$username = $uid;
$stmt->execute();

$result = $stmt->get_result();

$row = mysqli_fetch_assoc($result);
$hash_pw = $row['pwd'];
$dehash = password_verify($pwd, $hash_pw);

if($dehash == 0)
{
    header("Location: ../loginscreen.php?error=pwwrong");
    exit();
}else{

    $stmt2 = $connector->prepare("SELECT * FROM nutzer WHERE uid=? AND pwd=?");
    $stmt2->bind_param("ss", $username2, $password2);

    $username2 = $uid;
    $password2 = $hash_pw;

    $stmt2->execute();    

    $result = $stmt2->get_result();
    $stmt->close();

    if(!$row =$result->fetch_assoc()) 
    {
        echo "Your username or password is incorrect!";
    } else{
    $_SESSION['id'] = $row['id']; 
    $_SESSION['uid'] = $row['uid']; 
    $_SESSION['email'] = $row['email']; 
    $_SESSION['first'] = $row['first'];
    $_SESSION['last'] = $row['last'];
}

header("Location: ../loginscreen.php"); // go to page after signing in
}

The prepared statements work perfectly on XAMPP on my localhost but when i upload them on my webserver there is nothing happening after logging in. It is just a blank screen. My webserver is running on PHP 5.6 if that is important.

MagikarpSama
  • 323
  • 1
  • 11
  • 4
    If there's a blank screen, it might be throwing a 500 error. Check your error logs to see if there's a hint to what might be going on. – aynber Dec 27 '16 at 18:40
  • Does that mean that my result function is wrong? – MagikarpSama Dec 27 '16 at 18:45
  • 1
    Possible duplicate of [Call to undefined method mysqli\_stmt::get\_result](http://stackoverflow.com/questions/8321096/call-to-undefined-method-mysqli-stmtget-result) – aynber Dec 27 '16 at 18:46
  • The error i am getting: PHP Fatal error: Call to undefined method mysqli_stmt::get_result() in include/login.inc.php on line 34, referer: https://ntgamestudio.com/loginscreen.php – MagikarpSama Dec 27 '16 at 18:47
  • I will try working with that, thank you for your help! – MagikarpSama Dec 27 '16 at 18:48
  • i really tried everything but it still gives me this error: PHP Fatal error: Call to undefined method mysqli_stmt::get_result() although i dont have any get_result() functions anywhere in my code.. – MagikarpSama Dec 27 '16 at 19:45

1 Answers1

0

Just for anybody who will see this in the future. I saw that my hoster doesn´t support MYSQLnd which is required for the get_result() function. I just wrote it different with fetch() and bind_result(). There are many solution examples in the web.

MagikarpSama
  • 323
  • 1
  • 11