<?php // On récupère les informations de connection à notre base de données dans le tableau (array) $database require 'config/config2.php'; include 'functions/database.fn.php'; $db_database = $config['database']; $bdd = getPDOLink($config); $page = "backoffice/home_clubs.php"; if (!empty($_POST)) { if (isset($_POST['action']) and $_POST['action'] == "edit") { } else { try { $club_obj = new Cl_Club(); $data = $club_obj->club_update($_POST); if ($data) { $success = CLUB_UPDATE_SUCCESS; } //echo '<meta http-equiv="refresh" content="0;url='.$page.'">'; } catch (Exception $e) { $error = $e->getMessage(); } } } /* echo "<pre>"; print_r($_POST); echo "</pre>"; $query = "SELECT `USER_ID`,`NOM`,`PRENOM`,`ALIAS`,`RUE`,`NUMERO`,`CODE_POSTAL`,`LOCALITE`,`PAYS`,`TELEPHONE`,`GSM`,`EMAIL` FROM `$db_database`.`utilisateurs`";
/** * This method will handle user login process * @param array $data * @return boolean true or false based on success or failure */ public function login(array $data) { $_SESSION['logged_in'] = false; if (!empty($data)) { // Trim all the incoming data: $trimmed_data = array_map('trim', $data); // escape variables for security $email = mysqli_real_escape_string($this->_con, $trimmed_data['email']); $password = mysqli_real_escape_string($this->_con, $trimmed_data['password']); if (!$email || !$password) { throw new Exception(LOGIN_FIELDS_MISSING); } $password = md5($password); $query = "SELECT USER_ID, NOM, EMAIL, created FROM utilisateurs where EMAIL = '{$email}' and PASSWORD = '******' "; $result = mysqli_query($this->_con, $query); $data = mysqli_fetch_assoc($result); $count = mysqli_num_rows($result); mysqli_close($this->_con); if ($count == 1) { // On récupère les informations de connection à notre base de données dans le tableau (array) $database require 'config/config.php'; include 'functions/database.fn.php'; $bdd = getPDOLink($config); $sql = "SELECT count(*) FROM `user_login`.`sessions` WHERE `INDEXLOGOUT` = 0"; $result = $bdd->prepare($sql); $result->execute(); $count = $result->fetchColumn(); $session_id = $_SESSION['id']; $_SESSION = $data; $_SESSION['logged_in'] = true; $_SESSION['id'] = $session_id; if ($count == 0) { $bdd->exec('INSERT INTO `user_login`.`sessions` (`CLUB`, `UTILISATEUR`, `DATEHEURELOGIN`, `INDEXLOGIN`) VALUES (' . $count . ',2,Now(),12345)'); } return true; } else { throw new Exception(LOGIN_FAIL); } } else { throw new Exception(LOGIN_FIELDS_MISSING); } }