Skip to content

Instantly share code, notes, and snippets.

@pujie
Created October 19, 2015 03:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pujie/a539735f6aecb58649cd to your computer and use it in GitHub Desktop.
Save pujie/a539735f6aecb58649cd to your computer and use it in GitHub Desktop.
simulasi login 2
<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>
<?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