Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- ?>
- <form method="POST">
- E-mail: <input type='email' name='email'>
- Senha: <input type='password' name='senha'>
- <input type="submit" value='submit'>
- </form>
- <?php
- if( !empty($_POST['email']) && isset($_POST['email']) && !empty($_POST['senha']) && isset($_POST['senha']) ){
- $email = addslashes($_POST['email']);
- $senha = md5($_POST['senha']);
- try{
- $dsn = 'mysql:dbname=blog;host=localhost';
- $dbuser = 'root';
- $dbpass = 'root';
- $pdo = new PDO($dsn,$dbuser,$dbpass);
- $sql = $pdo->query("SELECT * FROM usuarios WHERE email='$email' and senha='$senha'");
- if($sql->rowCount() > 0){
- $dado = $sql->fetch();
- $_SESSION['id'] = $dado['id'];
- header("Location: index.php");
- } else {
- print 'Usuário e/ou senha incorretos.';
- }
- }catch(PDOException $e){
- print 'error: '.$e->getMessage();
- }
- }
- ?>
Add Comment
Please, Sign In to add comment