Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. <?php
  2. include_once "includes/valid/validUser.php";
  3. include_once "includes/bdConection.php";
  4. ?>
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6. <head>
  7. <title>Login</title>
  8. <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta charset="UTF-8">
  9.  
  10. </head>
  11. <body>
  12.  
  13. <div id="content">
  14. <div class="testbox">
  15. <h1>Inicio de sesi&oacute;n</h1><hr/>
  16. <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" href="#" >
  17. <label id="icon" for="name"><i class="icon-user"></i></label>
  18. <input type="number" class="inputLogin" name="userNameLogin" placeholder="Código de Usuario" required />
  19. <label id="icon" for="name"><i class="icon-shield"></i></label>
  20. <input type="password" class="inputLogin" name="passwordLogin" value="" placeholder="Contraseña" required/>
  21. <input type="submit" class= "btn btn-info btn-responsive btninter center" id="button" name="submit" value="Ingresar"/>
  22. </form>
  23. </div>
  24. </div>
  25. </body>
  26. </html>
  27.  
  28. <?php
  29. include_once "includes/bdConection.php";
  30.  
  31. if(isset($_POST['submit'])){
  32.  
  33. $userName=trim($_POST["userNameLogin"]);
  34. $password=trim($_POST["passwordLogin"]);
  35. $password=md5($password);
  36. $query = "SELECT * FROM users WHERE id_user = '$userName' AND pw = '$password';";
  37. $result = pg_query($conn, $query) or die('Query failed: ' . pg_last_error());
  38. if(pg_num_rows($result) != 1) {
  39. //do error stuff
  40. $error = "<b> Usuario o contraseña incorrectos</b>";
  41.  
  42. }
  43. else
  44. {
  45.  
  46. session_start();
  47. $_SESSION['varname'] = $userName;
  48. $_SESSION['start'] = time();
  49. $_SESSION['expire'] = $_SESSION['start'] + (60 * 60);
  50. echo "Welcome " . $userName;
  51. header("Location: ../index.php");
  52. exit;
  53. }
  54.  
  55. }
  56.  
  57.  
  58. echo "<p> $error </p>";
  59. ?>
  60.  
  61. echo hash('ripemd160', 'The quick brown fox jumped over the lazy dog.');
  62.  
  63. ec457d0a974c48d5685a7efa03d137dc8bbde7e3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement