Guest User

Untitled

a guest
Aug 28th, 2018
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. Login system with MooTools (Ajax)
  2. //Connect, prepare, execute and bind
  3. $mysqli = new mysqli('localhost','root','','db');
  4. $stmt = $mysqli->prepare("SELECT id, username, password FROM users WHERE username=?");
  5. $stmt->bind_param('s',//I need to get the typed in username from the index.php file);
  6. $stmt->execute();
  7. $stmt->store_result();
  8. $stmt->bind_result($get_id, $get_username, $get_password);
  9. $stmt->fetch();
  10.  
  11. if($stmt->num_rows!=0){
  12. //Check if the passwords match
  13. if($get_password==//I need the typed in password here){
  14. echo('Passwords match');
  15. }
  16. }
  17. else{
  18. echo 'User dosn't exist';
  19. }
  20.  
  21. // JavaScript (MooTools):
  22. var myRequest = new Request([method:"POST", url:"login-process.php", onSuccess: function(responseText){
  23. document.id('response').set('text', responseText);
  24. }]);
  25. myRequest.send("username="+username+"&password="+password);
Add Comment
Please, Sign In to add comment