Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php session_start();
- if (isset ($_SESSION['usuario'])){
- header('Location: ../php/home.php');
- }
- $errores = '';
- if ($_SERVER['REQUEST_METHOD'] =='POST') {
- $email = filter_var(strtolower($_POST['email']), FILTER_SANITIZE_STRING);
- $password = $_POST['password'];
- $password = hash('sha512', $password);
- try {
- $conexion = new PDO('mysql:host=localhost;dbname=drivers_parade_club', 'root', ' ') ;
- // la conexión a la base de datos se hace bien.
- } catch (PDOException $e) {
- echo "Error". $e->getMessage();;
- }
- $statement = $conexion->prepare ('SELECT * FROM usuarios WHERE email = :email AND pass = :password');
- $statement->execute(array(
- ':email'=> $email,
- ':password'=>$password
- ));
- $resultado = $statement->fetch();
- if ($resultado !==false) {
- $_SESSION ['usuario'] = $email;
- header('Location: ../php/home.php');
- }else {
- $errores= '<li style="color:red;"> Tu e-mail o contraseña no son correctos</li>';
- }
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <title>Drivers Parade Club</title>
- <!-- Bootstrap CSS CDN -->
- <link rel="stylesheet" href="../css/bootstrap.css">
- <!-- Our Custom CSS -->
- <link rel="stylesheet" href="../css/estilos_login.css">
- <link rel="stylesheet" href="../css/mdb.css">
- <!--Icons CSS-->
- <link rel="stylesheet" href="../css/fontello.css">
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
- <script type="text/javascript" src="../js/mdb.min.js"></script>
- <!--Favicon-->
- <link rel="shortcut icon" href="../imagenes/logoprueba.jpg" sizes="64x64"/>
- </head>
- <body class="imagen">
- <div class="container">
- <div class="row">
- <div class="col">
- <nav class="navbar fixed-top navbar-expand-lg navbar-light white scrolling-navbar">
- <div class="text-center">
- <a href="php/contactologin.php" class="btn btn-default btn-rounded mb-4" data-toggle="modal" data-target="#modalContactForm">Contacto</a>
- </div>
- </nav>
- <div ></div>
- <!-- Material form login -->
- <div class="card " style="margin-top:25%">
- <h5 class="card-header warning-color white-text text-center py-4 " >
- <strong>Login</strong>
- </h5>
- <!--Card content-->
- <div class="card-body px-lg-5 pt-0">
- <!-- Form -->
- <form class="text-center formulario" style="color: #757575;" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>" method="POST" name="login">
- <!-- Email -->
- <div class="md-form">
- <input type="email" id="materialLoginFormEmail" class="form-control" name="email">
- <label for="materialLoginFormEmail">E-mail</label>
- </div>
- <!-- Password -->
- <div class="md-form">
- <input type="password" id="materialLoginFormPassword" class="form-control" name="password">
- <label for="materialLoginFormPassword">Contaseña</label>
- </div>
- <div class="d-flex justify-content-around">
- <div>
- <!-- Forgot password -->
- <a href=""></a>
- </div>
- </div>
- <!-- Sign in button -->
- <div class="text-center mt-4">
- <button class="btn btn-warning btn-lg mt-4" onclick="login.submit()">Login</button>
- </div>
- <br>
- <br>
- <?php if(!empty($errores)):?>
- <div class="error">
- <ul>
- <?php echo $errores;?>
- </ul>
- </div>
- <?php endif;?>
- <br>
- <br>
- <!-- Register -->
- <p>¿No eres miembro?
- <a href="php/registro.php">Registrate</a>
- </p>
- </div>
- </div>
- <!-- Material form login -->
Add Comment
Please, Sign In to add comment