-4

I do really need some help to explain me about my error. I am new about the mysqli can someone lend me some time to teach me about mysqli?

<?php
if(isset($_POST['txtlogin'])){
$username = $_POST['txtusername'];
    $password = md5($_POST['txtpassword']);
    $stmt = $link->prepare("SELECT username, password FROM users WHERE username=? AND  password=?");
    $stmt->bind_param('ss', $username, $password);
    $stmt->execute();
    $stmt->bind_result($username, $password);
    $stmt->store_result();
    if($stmt->num_rows == 1)  //To check if the row exists
        {
            while($stmt->fetch()) //fetching the contents of the row

              {$_SESSION['Logged'] = 1;
               $_SESSION['username'] = $username;
               echo 'Success!';
               exit();
               }

        }
        else {
            echo "INVALID USERNAME/PASSWORD Combination!";
        }
        $stmt->close();
    }
    else 
    {   

    }
$link->close();
?>
Engineer
  • 5,911
  • 4
  • 31
  • 58
MysEager
  • 11
  • 1
  • Does this answer your question? [mysqli\_fetch\_assoc() expects parameter / Call to a member function bind\_param() errors. How to get the actual mysql error and fix it?](https://stackoverflow.com/questions/22662488/mysqli-fetch-assoc-expects-parameter-call-to-a-member-function-bind-param) – Dharman Mar 04 '20 at 00:10

1 Answers1

-1

The error you quoted in your question occurs when you call a function of a class without using its object.

Problem is $link

$link should be a mysqli object, Like:

$link = new mysqli("yourhost", "youruser", "yourpassword", "yourdb");
Engineer
  • 5,911
  • 4
  • 31
  • 58