Guest User

Untitled

a guest
Feb 15th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. if (isset($_POST['remember'])) {
  2. session_set_cookie_params('604800');
  3. session_regenerate_id(true);
  4. }
  5.  
  6. $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
  7.  
  8. if ($mysqli->connect_errno) {
  9. echo "<p>MySQL error no {$mysqli->connect_errno} : {$mysqli->connect_error}</p>";
  10. exit();
  11. }
  12.  
  13. $sql = "SELECT * from kandokowapers WHERE username='{$username}' AND password='{$password}' LIMIT 1";
  14. $result = $mysqli->query($sql);
  15.  
  16. if ($result->num_rows != 1) {
  17. echo "<h3><strong>Error:</strong> Invalid Username/Password Combination Chikala Try Again</h3>";
  18. } else {
  19. // Authenticated, set session variables
  20. $user = $result->fetch_array();
  21. $_SESSION['user_id'] = $user['id'];
  22. $_SESSION['username'] = $user['username'];
  23. header("Location: profile.php");
  24. //do stuffs
  25. }
Add Comment
Please, Sign In to add comment