Guest User

Untitled

a guest
Aug 19th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.16 KB | None | 0 0
  1. <?php session_start();
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9. if (isset ($_SESSION['usuario'])){
  10.  
  11.  
  12.  
  13. header('Location: ../php/home.php');
  14.  
  15.  
  16.  
  17. }
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25. $errores = '';
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33. if ($_SERVER['REQUEST_METHOD'] =='POST') {
  34.  
  35.  
  36.  
  37. $email = filter_var(strtolower($_POST['email']), FILTER_SANITIZE_STRING);
  38.  
  39.  
  40.  
  41. $password = $_POST['password'];
  42.  
  43.  
  44.  
  45. $password = hash('sha512', $password);
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53. try {
  54.  
  55.  
  56.  
  57. $conexion = new PDO('mysql:host=localhost;dbname=drivers_parade_club', 'root', ' ') ;
  58.  
  59. // la conexión a la base de datos se hace bien.
  60.  
  61. } catch (PDOException $e) {
  62.  
  63.  
  64.  
  65. echo "Error". $e->getMessage();;
  66.  
  67.  
  68.  
  69. }
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77. $statement = $conexion->prepare ('SELECT * FROM usuarios WHERE email = :email AND pass = :password');
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85. $statement->execute(array(
  86.  
  87.  
  88.  
  89. ':email'=> $email,
  90.  
  91.  
  92.  
  93. ':password'=>$password
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101. ));
  102.  
  103.  
  104.  
  105. $resultado = $statement->fetch();
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113. if ($resultado !==false) {
  114.  
  115.  
  116.  
  117. $_SESSION ['usuario'] = $email;
  118.  
  119.  
  120.  
  121. header('Location: ../php/home.php');
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129. }else {
  130.  
  131.  
  132.  
  133. $errores= '<li style="color:red;"> Tu e-mail o contraseña no son correctos</li>';
  134.  
  135.  
  136.  
  137. }
  138.  
  139.  
  140.  
  141. }
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149. ?>
  150.  
  151.  
  152.  
  153. <!DOCTYPE html>
  154.  
  155.  
  156.  
  157. <html>
  158.  
  159.  
  160.  
  161. <head>
  162.  
  163.  
  164.  
  165. <meta charset="utf-8">
  166.  
  167.  
  168.  
  169. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  170.  
  171.  
  172.  
  173. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181. <title>Drivers Parade Club</title>
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189. <!-- Bootstrap CSS CDN -->
  190.  
  191.  
  192.  
  193. <link rel="stylesheet" href="../css/bootstrap.css">
  194.  
  195.  
  196.  
  197. <!-- Our Custom CSS -->
  198.  
  199.  
  200.  
  201. <link rel="stylesheet" href="../css/estilos_login.css">
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213. <link rel="stylesheet" href="../css/mdb.css">
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221. <!--Icons CSS-->
  222.  
  223.  
  224.  
  225. <link rel="stylesheet" href="../css/fontello.css">
  226.  
  227.  
  228.  
  229. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  230.  
  231.  
  232.  
  233. <script type="text/javascript" src="../js/mdb.min.js"></script>
  234.  
  235.  
  236.  
  237. <!--Favicon-->
  238.  
  239.  
  240.  
  241. <link rel="shortcut icon" href="../imagenes/logoprueba.jpg" sizes="64x64"/>
  242.  
  243.  
  244.  
  245. </head>
  246.  
  247.  
  248.  
  249. <body class="imagen">
  250.  
  251.  
  252.  
  253. <div class="container">
  254.  
  255.  
  256.  
  257. <div class="row">
  258.  
  259.  
  260.  
  261. <div class="col">
  262.  
  263.  
  264.  
  265. <nav class="navbar fixed-top navbar-expand-lg navbar-light white scrolling-navbar">
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273. <div class="text-center">
  274.  
  275.  
  276.  
  277. <a href="php/contactologin.php" class="btn btn-default btn-rounded mb-4" data-toggle="modal" data-target="#modalContactForm">Contacto</a>
  278.  
  279.  
  280.  
  281. </div>
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289. </nav>
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297. <div ></div>
  298.  
  299.  
  300.  
  301. <!-- Material form login -->
  302.  
  303.  
  304.  
  305. <div class="card " style="margin-top:25%">
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313. <h5 class="card-header warning-color white-text text-center py-4 " >
  314.  
  315.  
  316.  
  317. <strong>Login</strong>
  318.  
  319.  
  320.  
  321. </h5>
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329. <!--Card content-->
  330.  
  331.  
  332.  
  333. <div class="card-body px-lg-5 pt-0">
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341. <!-- Form -->
  342.  
  343.  
  344.  
  345. <form class="text-center formulario" style="color: #757575;" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>" method="POST" name="login">
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353. <!-- Email -->
  354.  
  355.  
  356.  
  357. <div class="md-form">
  358.  
  359.  
  360.  
  361. <input type="email" id="materialLoginFormEmail" class="form-control" name="email">
  362.  
  363.  
  364.  
  365. <label for="materialLoginFormEmail">E-mail</label>
  366.  
  367.  
  368.  
  369. </div>
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377. <!-- Password -->
  378.  
  379.  
  380.  
  381. <div class="md-form">
  382.  
  383.  
  384.  
  385. <input type="password" id="materialLoginFormPassword" class="form-control" name="password">
  386.  
  387.  
  388.  
  389. <label for="materialLoginFormPassword">Contaseña</label>
  390.  
  391.  
  392.  
  393. </div>
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401. <div class="d-flex justify-content-around">
  402.  
  403.  
  404.  
  405. <div>
  406.  
  407.  
  408.  
  409. <!-- Forgot password -->
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417. <a href=""></a>
  418.  
  419.  
  420.  
  421. </div>
  422.  
  423.  
  424.  
  425. </div>
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437. <!-- Sign in button -->
  438.  
  439.  
  440.  
  441. <div class="text-center mt-4">
  442.  
  443.  
  444.  
  445. <button class="btn btn-warning btn-lg mt-4" onclick="login.submit()">Login</button>
  446.  
  447.  
  448.  
  449. </div>
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461. <br>
  462.  
  463.  
  464.  
  465. <br>
  466.  
  467.  
  468.  
  469. <?php if(!empty($errores)):?>
  470.  
  471.  
  472.  
  473. <div class="error">
  474.  
  475.  
  476.  
  477. <ul>
  478.  
  479.  
  480.  
  481. <?php echo $errores;?>
  482.  
  483.  
  484.  
  485. </ul>
  486.  
  487.  
  488.  
  489. </div>
  490.  
  491.  
  492.  
  493. <?php endif;?>
  494.  
  495.  
  496.  
  497. <br>
  498.  
  499.  
  500.  
  501. <br>
  502.  
  503.  
  504.  
  505. <!-- Register -->
  506.  
  507.  
  508.  
  509. <p>¿No eres miembro?
  510.  
  511.  
  512.  
  513. <a href="php/registro.php">Registrate</a>
  514.  
  515.  
  516.  
  517. </p>
  518.  
  519.  
  520.  
  521. </div>
  522.  
  523.  
  524.  
  525. </div>
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537. <!-- Material form login -->
Add Comment
Please, Sign In to add comment