Answer the question
In order to leave comments, you need to log in
Using functions from one php file in another?
I include the core.php file in the core.api.php file to use the functions contained in it.
define(ROOT, $_SERVER['DOCUMENT_ROOT']);
require(ROOT.'/sys/core.php');
function check($pdo, $cookie_id, $cookie_hash){
if(empty($cookie_id) || empty($cookie_hash)){
return 0;
} else {
$sql = "SELECT hash FROM nv_users WHERE id='$cookie_id'";
if(!$stmt = $pdo->query($sql)){
return 0;
} else {
$row = $stmt->fetch(PDO::FETCH_ASSOC);
if(!$row){
return 0;
} else {
$db_hash = $row['hash'];
if($cookie_hash == $db_hash){
return $cookie_id;
}
return 0;
}
}
}
}
Answer the question
In order to leave comments, you need to log in
As always, the cockroach has ears in its legs.
If a function doesn't work, it's because it's being called from another file. Of course, how else?
If a function does not return what is expected, it means that incorrect data was passed to it.
Here is the data that you transmit, and you need to look.
Instead of on a file in which function lies.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question