Bonjour, j'aimerais savoirs d'ou vient l'erreur ? je souhait que le clients puisse ce connectée avec l'email ou le pseudo mais je ne trouve pas comment faire. Merci de votre aide
<?php
if ($user -> LoggedIn())
{
?>
<div class="alert alert-success"><h4>Vous êtes déjà connecté, redirection...</h4><span></span><div></div></div>
<?php
echo "<meta http-equiv=\"refresh\" content=\"2;url=index.php\">";
}
if (isset($_POST['loginBtn']))
{
$username = $_POST['username'];
$email = $_POST['email'];
$password = $_POST['password'];
$errors = array();
if (!ctype_alnum($username) || strlen($username) < 2 || strlen($username) > 20)
{
$errors[] = 'Utilisateur incorrecte';
}
if (!ctype_alnum($username) || strlen($username) < 2 || strlen($username) > 20)
{
$errors[] = 'Email incorrecte';
}
if (empty($username) || empty($password))
{
$errors[] = 'Merci de verifier les champs';
}
if (empty($errors))
{
$SQLCheckLogin = $odb -> prepare("SELECT COUNT(*) FROM 'users' WHERE 'username' = :username AND 'email' = :email AND 'password' = :password");
$SQLCheckLogin -> execute(array(':username' => $username, ':email' => $email, ':password' => $password));
$countLogin = $SQLCheckLogin -> fetchColumn(0);
if ($countLogin == 1)
{
$SQLGetInfo = $odb -> prepare("SELECT 'username', 'email', 'ID', 'status' FROM 'users' WHERE 'username' = :username AND 'email' = :email AND 'password' = :password");
$SQLGetInfo -> execute(array(':username' => $username, ':email' => $email, ':password' => $password));
$userInfo = $SQLGetInfo -> fetch(PDO::FETCH_ASSOC);
if ($userInfo['status'] == "0")
{
$_SESSION['username'] = $userInfo['username'];
$_SESSION['ID'] = $userInfo['ID'];
$_SESSION['email'] = $userInfo['email'];
$ip = getRealIpAddr();
$SQL = $odb -> prepare('INSERT INTO 'loginlogs' VALUES(:username, :ip, :password, :email, UNIX_TIMESTAMP(), "")');
$SQL -> execute(array(':ip' => $ip, ':password' => $password, ':email' => $email, ':username' => $username ));
?>
<div class="alert alert-success"><h4>Connexion réussie, redirection...</h4><span></span><div></div></div>
<?php
echo '<meta http-equiv="refresh" content="2;url=index.php"';
}
else
{
echo '<div class="alert alert-danger"><h4>Vous êtes bannis!</h4><span></span><div>Raison: '.$userInfo['status'].'</div></div>';
}
}
else
{
echo '<div class="alert alert-danger"><h4>ERREUR:</h4><span></span><div> - Connexion échouée, mot de passe incorrecte</div></div>';
}
}
else
{
echo '<div class="alert alert-danger"><h4>ERREUR:</h4><span></span><div>';
foreach($errors as $error)
{
echo '- '.$error.'<br />';
}
echo '</div></div>';
}
}
?>
<form method="post" action="">
<form role="form">
<div class="form-group">
<a href="#" class="pull-right label-forgot">Email oublié?</a>
<label for="inputUsernameEmail">Pseudo ou Email</label>
<input id="username" type="text" id="inputUsernameEmail" class="form-control" name="username email">
</div>
<div class="form-group">
<a href="#" class="pull-right label-forgot">Mot de passe oublié?</a>
<label for="inputPassword">Mot de passe</label>
<input id="password" type="password" id="inputPassword" class="form-control" name="password">
</div>
<div class="checkbox pull-left">
<label>
<input type="checkbox">Se souvenir de moi</label>
</div>
<button id="loginBtn" class="btn btn btn-primary pull-right" type="submit" name="loginBtn">
Connexion
</button>
</form></form>
Afficher la suite