X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=lib%2Futils.php;h=8fdb0aa66d7834a235d0d8ce05d08a1d6e965df6;hb=77e900523470eb7de54f2b92794177b54c3ad1bf;hp=e6e0365a410f6c45f460e2c455a1026623f6d678;hpb=6405835a808d5ac4986ff463a7be0b146058440d;p=Project_webapp.git diff --git a/lib/utils.php b/lib/utils.php index e6e0365..8fdb0aa 100644 --- a/lib/utils.php +++ b/lib/utils.php @@ -1,9 +1,69 @@ prepare_query($sql_pquery); + $connection->prepared_query_bind_param("s", array($email)); + $connection->run_prepared_query(); + $connection->get_pquery_result(); + $row = $connection->get_result_array(); + $connection->close_prepared_query(); + if (!empty($row[0])) { + return true; + } else { + return false; + } +} + +function chk_password($email, $password) +{ + global $connection; + $sql_pquery = "select PasswordCl from CLIENTS where EmailCl = ?"; + $connection->prepare_query($sql_pquery); + $connection->prepared_query_bind_param("s", array($email)); + $connection->run_prepared_query(); + $connection->get_pquery_result(); + $row = $connection->get_result_array(); + $connection->close_prepared_query(); + if (password_verify($password, $row[0])) { + return true; + } else { + return false; + } +} + +function chk_logged_in() +{ + if (isset($_SESSION['email']) && isset($_SESSION['IP_address'])) { + return true; + } else { + return false; + } +} + +function redirect($url, $delay) +{ + header("refresh:$delay; url=$url"); +} + ?>