Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Login system with MooTools (Ajax)
- //Connect, prepare, execute and bind
- $mysqli = new mysqli('localhost','root','','db');
- $stmt = $mysqli->prepare("SELECT id, username, password FROM users WHERE username=?");
- $stmt->bind_param('s',//I need to get the typed in username from the index.php file);
- $stmt->execute();
- $stmt->store_result();
- $stmt->bind_result($get_id, $get_username, $get_password);
- $stmt->fetch();
- if($stmt->num_rows!=0){
- //Check if the passwords match
- if($get_password==//I need the typed in password here){
- echo('Passwords match');
- }
- }
- else{
- echo 'User dosn't exist';
- }
- // JavaScript (MooTools):
- var myRequest = new Request([method:"POST", url:"login-process.php", onSuccess: function(responseText){
- document.id('response').set('text', responseText);
- }]);
- myRequest.send("username="+username+"&password="+password);
Add Comment
Please, Sign In to add comment