Advertisement
Guest User

Untitled

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