Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. <?php session_start();
  2. Include("config.php");
  3. $conexion = new mysqli($host_db, $user_db, $pass_db, $db_nam
  4. if ($conexion->connect_error)
  5. {
  6. die("La conexion falló: " . $conexion->connect_error);
  7. }
  8. $username = $_POST['username']; //read the usernamein index.html
  9. $password = $_POST['password']; //read the password in index.html
  10. $sql = "SELECT * FROM $tbl_name WHERE usuario = '$username'";
  11. $result = $conexion->query($sql);
  12. if ($result->num_rows > 0) {
  13. }$row = $result->fetch_array(MYSQLI_ASSOC);
  14. if (password_verify($password, $row['password'])) {
  15.  
  16. $_SESSION['loggedin'] = true;
  17. $_SESSION['username'] = $username;
  18. $_SESSION['start'] = time();
  19. $_SESSION['expire'] = $_SESSION['start'] + (5 * 60);
  20.  
  21. echo "Bienvenido! " . $_SESSION['username'];
  22. echo "<br><br><a href=panel-control.php>Panel de Control</a>";
  23. }else {
  24. echo "Username or Password incorrect.";
  25. echo "<br><a href='../index.html'>Try Again</a>"; }
  26. mysqli_close($conexion);
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement