0
// User's Login 
    public function Login($username, $pass, $table_name){
        $password = SHA1($pass);
        if(!empty($username) && !empty($password)){
            $user = $this->link->prepare("SELECT * FROM $table_name WHERE username=? AND pass=?");
            $user->bind_param("ss", $username, $password);
            $user->execute();
            $result = $user->get_result();


                    if($result->num_rows==1){
                        session_start();
                        $row=$result->fetch_assoc();
                        $loginuser = $_SESSION['name']=$row['username'];
                        $logged_id =$_SESSION['id']=$row['id'];
                        $phone_id =$_SESSION['phone']=$row['phone'];
                        $identity =$_SESSION['identity']=$row['id'].$row['phone'];

                        if(isset($_SESSION['name'])) {
                            ob_start();
                            header('Location: dashboard?id='.$row['id'].$row['phone']);
                                exit();
                            } else { 
                                echo "<p class='col-sm-4 mx-auto mt-5 alert alert-danger text-center'>Invalid Session, Try Again</p>";  
                            }                       
                    }else{
                        echo "<p class='col-sm-4 mx-auto mt-5 alert alert-danger text-center'>Invalid Username and Password</p>";   
                    }   
        }else{
            echo "<p class='col-sm-4 mx-auto mt-5 alert alert-danger text-center'> Empty Login Details </p>";
        }
     }

This is the Function that processes my Login Form, it works on Xamp but gives error on live server. Fatal error: Uncaught Error: Call to undefined method mysqli_stmt::get_result() in

Fjay
  • 23
  • 4
  • 2
    `get_result` is only available when using the mysqlnd driver, which it seems your hosting does not provide. – Jonnix Mar 06 '19 at 14:55
  • 1
    this may have your answer https://stackoverflow.com/questions/8321096/call-to-undefined-method-mysqli-stmtget-result – Alex Mar 06 '19 at 14:57

1 Answers1

1

It requires the mysqlnd driver... if it isn't installed on your webspace you will have to work with BIND_RESULT & FETCH!

extension=php_mysqli_mysqlnd.dll in php.ini; and restart Apache2

Please read the user notes for this method:

http://php.net/manual/en/mysqli-stmt.get-result.php

https://secure.php.net/manual/en/mysqli-stmt.bind-result.php

https://secure.php.net/manual/en/mysqli-stmt.fetch.php

Nikhil Lende
  • 119
  • 7