par
Sylvestre » 31 juil. 2019, 21:13
Bonsoir,
Je voudrais faire une page connexion, inscription, profil
Donc tout est ok sauf lors de la connexion ou sa m'affice ceci :
<?php
session_start();
include 'datebase.php';
if(isset($_POST['formconnexion'])) {
$mailconnect = htmlspecialchars($_POST['mailconnect']);
$mdpconnect = sha1($_POST['mdpconnect']);
if(!empty($mailconnect) AND !empty($mdpconnect)) {
$requser = $bdd->prepare("SELECT * FROM user WHERE mail = ? AND motdepasse = ?");
$requser->execute(array($mailconnect, $mdpconnect));
$userexist = $requser->rowCount();
if($userexist == 1) {
$userinfo = $requser->fetch();
$_SESSION['id'] = $userinfo['id'];
$_SESSION['pseudo'] = $userinfo['pseudo'];
$_SESSION['mail'] = $userinfo['mail'];
header("Location: profil.php?id=".$_SESSION['id']);
} else {
$erreur = "Mauvais mail ou mot de passe !";
}
} else {
$erreur = "Tous les champs doivent être complétés !";
}
}
?>
<html>
<head>
<title>Connexion</title>
<meta charset="utf-8">
</head>
<body>
<div align="center">
<h2>Connexion</h2>
<br /><br />
<form method="POST" action="">
<input type="email" name="mailconnect" placeholder="Mail" />
<input type="password" name="mdpconnect" placeholder="Mot de passe" />
<br /><br />
<input type="submit" name="formconnexion" value="Se connecter !" />
</form>
<?php
if(isset($erreur)) {
echo '<font color="red">'.$erreur."</font>";
}
?>
</div>
</body>
</html>
Merciiii
Bonsoir,
Je voudrais faire une page connexion, inscription, profil
Donc tout est ok sauf lors de la connexion ou sa m'affice ceci :
[img]https://image.noelshack.com/minis/2019/31/3/1564600230-capture.png[/img]
[PHP]<?php
session_start();
include 'datebase.php';
if(isset($_POST['formconnexion'])) {
$mailconnect = htmlspecialchars($_POST['mailconnect']);
$mdpconnect = sha1($_POST['mdpconnect']);
if(!empty($mailconnect) AND !empty($mdpconnect)) {
$requser = $bdd->prepare("SELECT * FROM user WHERE mail = ? AND motdepasse = ?");
$requser->execute(array($mailconnect, $mdpconnect));
$userexist = $requser->rowCount();
if($userexist == 1) {
$userinfo = $requser->fetch();
$_SESSION['id'] = $userinfo['id'];
$_SESSION['pseudo'] = $userinfo['pseudo'];
$_SESSION['mail'] = $userinfo['mail'];
header("Location: profil.php?id=".$_SESSION['id']);
} else {
$erreur = "Mauvais mail ou mot de passe !";
}
} else {
$erreur = "Tous les champs doivent être complétés !";
}
}
?>[/PHP]
[html]<html>
<head>
<title>Connexion</title>
<meta charset="utf-8">
</head>
<body>
<div align="center">
<h2>Connexion</h2>
<br /><br />
<form method="POST" action="">
<input type="email" name="mailconnect" placeholder="Mail" />
<input type="password" name="mdpconnect" placeholder="Mot de passe" />
<br /><br />
<input type="submit" name="formconnexion" value="Se connecter !" />
</form>
<?php
if(isset($erreur)) {
echo '<font color="red">'.$erreur."</font>";
}
?>
</div>
</body>
</html>[/html]
Merciiii