Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. $db_host = "localhost";
  5. $db_user = "root";
  6. $db_pass = "thhdfhhfh";
  7. $db_name = "users";
  8.  
  9. try {
  10. $time = date('Y-m-d h:i:s');
  11. $username = $_SESSION['username'];
  12.  
  13. $db_conn = new PDO("mysql:host={$db_host};dbname={$db_name}",$db_user,$db_pass);
  14. $db_conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  15.  
  16. $stmt = $db_conn->prepare("UPDATE users SET lastlogin = :lastlogin, logincount = :logincount + :add WHERE username = '$username'");
  17. $stmt->bindParam(':lastlogin', $time);
  18. $stmt->bindParam(':add', 1);
  19. $stmt->execute();
  20. session_destroy();
  21. header('location:index.php');
  22.  
  23.  
  24. }
  25. catch(PDOException $e)
  26. {
  27. echo "Error:" . $e->getMessage();
  28. }
  29. $db_conn = null;
  30.  
  31.  
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement