X-Git-Url: https://git.piment-noir.org/?p=Project_webapp.git;a=blobdiff_plain;f=lib%2Futils.php;h=bc5db9b6a6026aed5173b9083f60d3b89f7e651d;hp=d937db729cb9f78b9bd54109c811136289de9e18;hb=a96fefe119b8c91c2f5ae6ad04e11af676e5540b;hpb=b5f60f89589412e18b51326378ab13b9a4fa0f19 diff --git a/lib/utils.php b/lib/utils.php index d937db7..bc5db9b 100644 --- a/lib/utils.php +++ b/lib/utils.php @@ -1,5 +1,6 @@ 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'])) { + return true; + } else { + return false; + } +} + +function redirect($url, $delay) +{ + header("refresh:$delay; url=$url"); +} + ?>