Création d'un systeme de connexion php/html/mysql
Re-salut la compagnie!
Me voilà dans un nouveau problème :
J'essaie de créer un système de connexion, mais ca n'arrive jamais là où j'aimerais que le code arrive, c'est à dire sur google.be... Pouvez-vous m'aider?
Ma base de donnée : Cocoon
Ma table : all_accounts
Voici mon code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| <?php
if(isset($_POST['submit'])){
$email= htmlentities(trim($_POST["email"]));
$password= htmlentities(trim($_POST["password"]));
if ($email&&$password){
$hostname='localhost';
$username='root';
$sqlpassword='';
$db = new PDO("mysql:host=$hostname;dbname=cocoon;charset=utf8mb4",$username,$sqlpassword);
$password=md5($password);
$res = $DB->query("SELECT COUNT(*) FROM all_accounts WHERE email ='$email'&&password ='$password'");
$num_rows = $res->fetchColumn();
echo $num_rows;
if ($num_rows==1){
header('Location: http://google.be');
}
}
}
?>
<html>
<head>
<title>Cocoon - Connexion</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/principal.css">
</head>
<body>
<img class="displayedVertical reduce" src="cocoon-logo.png" alt="Cocoon logo" />
<div class="centered">
<form class="login-form" method="POST" action="connexion.php">
<label>
<input type="email" name="email" required placeholder="Adresse e-mail ou mobile">
</label>
<br>
<label>
<input type="password" name="password" required placeholder="Mot de passe">
</label>
<br>
<label>
<input type="submit" value="Connexion">
</label>
</form>
<a class="inscription" href="registration.html">S'inscrire sur Cocoon</a>
<a class="smaller" href="index.html">Besoin d'aide?</a>
</div>
</body>
</html> |
Merci d'avance pour! votre réponse