I am getting the mentioned error. I have the database connection in conn.php which I am including in fn.php. However, on a particular line it is giving the error
Notice: Undefined variable: rezistent in fn.php on line 16
Line 16 is:
$a = mysqli_query($rezistent, "SELECT is_verified FROM users WHERE veri_key = '$key'") or die(mysqli_error());
Here's my conn.php
<?php
$user = "mmoin";
$pass = "pass";
$host = "localhost";
$dbname = "rezistent";
$rezistent = mysqli_connect($host, $user, $pass, $dbname) or die("cannot connect with database");
?>
and here's the fn.php
<?php
include "conn.php";
function hashit($v){
$hash = md5($v);
$hash .= rand(11,99);
return $hash;
}
function user_verification($k){
$account_type = substr($k, 0, 1);
$key = substr($k, 1);
$msg_to_display = "";
if($account_type == "h" || $account_type == "t"){
$a = mysqli_query($rezistent, "SELECT is_verified FROM users WHERE veri_key = '$key'") or die(mysqli_error());
$rows = mysqli_num_rows($a);
if($rows > 0){
mysqli_query($rezistent, "UPDATE users SET is_verified = '1' WHERE veri_key='$key'");
$msg_to_display = "User successfully verified. Please use the login link to login with your credentials.";
}
}
else{
$msg_to_display = "There seems to be a problem with the verification key. Please try again from the link provided in the email.";
}
return $msg_to_display;
}
?>
What can be the problem? I have tried even connecting with database immediately before the function but it still gives the same notice message.