This repository has been archived on 2021-12-22. You can view files and clone it, but cannot push or open issues or pull requests.
blog-legacy/lib/users.php

31 lines
561 B
PHP

<?php
function isValid($login, $password){
require('lib/db.php');
$req = $db->prepare("SELECT ID, password FROM users WHERE name = ?");
if($req->execute(array($login))){
$data = $req->fetch();
if(password_verify($password, $data['password'])){
return $data['ID'];
}else{
return NULL;
}
}else{
return NULL;
}
}
function getUserName($id){
require('lib/db.php');
$req = $db->prepare("SELECT name FROM users WHERE ID = ?");
if($req->execute(array($id))){
$data = $req->fetch();
return $data["name"];
}else{
return NULL;
}
}