34 lines
695 B
PHP
34 lines
695 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
function isEmpty(array $array){
|
|
foreach ($array as $value => $content) {
|
|
if (empty($content)){
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
function username_taken(object $pdo, string $username){
|
|
if (username_search($pdo, $username)) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function hash_password(string $pwd) {
|
|
$hashed_pw = password_hash($pwd,PASSWORD_BCRYPT,["cost"=>12]);
|
|
return $hashed_pw;
|
|
}
|
|
|
|
function user_register(object $pdo, string $username, string $pwd) {
|
|
user_write($pdo, $username, hash_password($pwd));
|
|
}
|
|
|
|
function print_errors(){
|
|
check_errors();
|
|
} |