0

I have this function on my function.php

function getPassword($username, $conn){
    if ($stmt2 = mysqli_prepare($conn, "SELECT data FROM xf_user_authenticate WHERE username = ?")){
        mysqli_stmt_bind_param($stmt2, "s", $username);

        mysqli_stmt_execute($stmt2);

        mysqli_stmt_bind_result($stmt2, $password);
        mysqli_stmt_fetch($stmt2);

        mysqli_stmt_close($stmt2);
        $password = substr($password, 22, -3);
        return $password;
    }

}

And I have a check.php file that's give me this error

Notice: Undefined variable: username
Notice: Undefined variable: conn

I go with global $username but the selection from database not work. Why its give me this error?

Dharman
  • 30,962
  • 25
  • 85
  • 135
DanN
  • 1
  • 1
  • Possible duplicate of [Reference: What is variable scope, which variables are accessible from where and what are "undefined variable" errors?](https://stackoverflow.com/questions/16959576/reference-what-is-variable-scope-which-variables-are-accessible-from-where-and) – Dharman Oct 20 '19 at 11:33

2 Answers2

0

Please, provide the content of check.php file

0

if(!empty($xen_password = getPassword($username, $conn)))
{
    if(checkPassword($password, $xen_password))
    {
        echo "p1<br>";
    }
    else
    {
        echo "p0<br>";
    }
}
DanN
  • 1
  • 1