Last active
August 29, 2015 14:11
-
-
Save FreakDev/0ced2c83d9d345773b4b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
global $bdd; | |
try { | |
$bdd = new PDO("mysql:host=localhost;dbname=todo_tp;unix_socket=/home/mathiasd/.mysql/mysql.sock", "root", "root"); | |
$bdd->exec('SET NAMES utf8'); | |
} catch (Exception $e) { | |
die('Can\'t connect to MySql Serveur : ' . $e->getMessage()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include ('includes/bdd.php'); | |
$message = ""; | |
if (isset($_POST['login'])) { | |
$sql = "SELECT * FROM user WHERE nickname = '" . $_POST['nickname'] . "' AND password = '" . $_POST['password'] . "'"; | |
$stmt = $bdd->prepare($sql); | |
$stmt->execute(); | |
if ($stmt->rowCount() === 1) { | |
$dataUser = $stmt->fetch(PDO::FETCH_ASSOC); | |
header("Location: index.php"); | |
exit(); | |
} else { | |
$message = "Failed login"; | |
} | |
} | |
include ('templates/login.phtml'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php include ('header.phtml'); ?> | |
<h2>Please Log in</h2> | |
<?php echo $message ?> | |
<form method="POST" action="login.php"> | |
<label for="_nickname">Login</label><br/> | |
<input id="_nickname" name="nickname" type="text" value="" /><br/> | |
<label for="_password">Password</label><br/> | |
<input id="_password" name="password" type="text" value="" /><br/> | |
<input type="submit" name="login" value="Login"> | |
</form> | |
<?php include ('footer.phtml'); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment