Created
October 19, 2015 03:20
-
-
Save pujie/a539735f6aecb58649cd to your computer and use it in GitHub Desktop.
simulasi login 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> | |
</head> | |
<body> | |
<div> | |
<input type="text" name="user" id="user"><br /> | |
<input type="text" name="pass" id="pass"><br /> | |
<button id="submit" >Login</button> | |
</div> | |
<script type="text/javascript"> | |
(function($){ | |
function gethost(){ | |
var url = window.location; | |
return url.host; | |
} | |
$("#submit").click(function(){ | |
$.ajax({ | |
url:'http://'+gethost()+'/loginprocess.php', | |
data:{name:$("#user").val(),pass:$("#pass").val()}, | |
type:'post', | |
success:function(data){ | |
if(data==="sukses"){ | |
window.location.href = 'http://padi.net.id'; | |
} | |
alert("tidak bisa login, username/password tidak cocok"); | |
}, | |
error:function(){ | |
alert("program error"); | |
} | |
}); | |
}); | |
}(jQuery)); | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$params = $_POST; | |
$users = array( | |
"budi"=>"budi123", | |
"yudi"=>"yudi123", | |
"rudi"=>"rudi123", | |
"dudi"=>"dudi123", | |
"sudi"=>"sudi123", | |
); | |
if($users[$params['name']]===$params['pass']){ | |
echo 'sukses'; | |
}else{ | |
echo 'gagal'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment