<?php require_once "model/loginManage.php"; if (isset($_SESSION['userId'])) { header('Location: index.php'); exit; } else { $error = ''; $login = new login(); if (isset($_POST['nickname'])) { $salt = 'zezjaejzeoakzodkozdkozadkoazdoazkdokaodkazodkozakdoazdkoazkdaozdaokdoakzodkazodkaodkazodkoakoladkaodkaodkoakolkoo'; $_POST['password'] = trim(htmlentities(sha1(sha1($_POST['password']) . $salt))); $result = $login->loginUser($pdo); if ($result === false) { $error = "Votre pseudo est introuvable !"; } elseif (empty($_POST['password'])) { $error = "Veuillez rentrer un password !"; } elseif ($_POST['password'] != $result['password']) { $error = "Mot de passe incorrect"; } else { if ($result['rank'] == 2) { $_SESSION['admin'] = $result['id']; $_SESSION['userId'] = $result['id']; } else { $_SESSION['userId'] = $result['id']; } header('Location: index.php?pages=loginOk'); exit; } } }
<?php //login ini_set('display_errors', 1); error_reporting(E_ALL); if (isset($_POST['username']) && isset($_POST['password'])) { require_once '../clases/classLogin.php'; $email = $_POST['username']; $password = $_POST['password']; $login = new login(); $result = $login->loginUser($email); $row = mysqli_fetch_array($result); if ($row !== null) { if ($row["password"] == $password) { session_start(); $_SESSION['emailUsuario'] = $row['email']; $_SESSION['passwordUsuario'] = $row['password']; $_SESSION['nombreUsuario'] = $row['nombre']; $_SESSION['apellidoUsuario'] = $row['apellido']; echo 'no_errors'; //header("Location: http://localhost/Gym-Trainer/inicio.php"); } else { echo "Password incorrecto"; } } else { echo "El usuario o password son incorrectos"; } } else { echo "Llenar todos los campos"; }