Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(!isset($_SESSION['userId'])){
- // Jeżeli użytkownik nie jest zalogowany - wyświetl formularz logowania:
- if(!isset($_POST['sub_loginUser'])){
- // Jeżeli formularz nie został wysłany wyświetl go:
- include_once 'sites/form-userLogin.html.php';
- } else {
- // Jeżeli formularz został wysłąny
- if(empty($_POST['userEmail']) OR empty($_POST['userPassword'])){
- $alert = new Alert();
- $alert->showAlert('warning', 'Uzupełnij <strong>wszystkie</strong> dane logowania.');
- include_once 'sites/form-userLogin.html.php';
- } else {
- try {
- include_once 'connect.php';
- $s = $pdo->prepare('SELECT email, password FROM users WHERE email = :email AND password = :password');
- $s->bindValue(':email', $_POST['userEmail']);
- $s->bindValue(':password', SHA1($_POST['userPassword']));
- $s->execute();
- } catch (PDOException $e) {
- $alert = new Alert();
- $alert->showAlert('warning', 'Wystąpił błąd w trakcie pobierania danych logowania do sprawdzenia.');
- }
- /*
- ------------------------------------------------------------------------------------
- Funkcja oblicza ilość zwróconych wierszy, czyli defakto ile osób jest w bazie danych
- Źródło: http://php.net/manual/en/pdostatement.rowcount.php
- $count = $s->rowCount();
- ------------------------------------------------------------------------------------
- */
- $count = $s->rowCount();
- echo '<p>Podliczone <strong>rowCount</strong>: '.$count.'</p>';
- if($count != 0){
- $alert = new Alert();
- $alert->showAlert('success', 'Istnieje taka osoba w Naszej bazie danych.');
- } else {
- $alert = new Alert();
- $alert->showAlert('danger', 'Taka osoba nie istnieje w Naszej bazei danych.');
- }
- $alert = new Alert();
- $alert->showAlert('success', 'Poprawnie wypełniłeś formularz logowania.');
- $s->closeCursor();
- $pdo = null;
- }
- }
- } else {
- // Jeżeli użytkownik jest zalogowany sprawdź, czy formularz logowania został wysłany
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement