Örnek sisteme giriş için kullanıcı adını check etmek
$(document).ready(function(){
$(‘#username’).keyup(username_check);
});
function username_check(){
var username = $(‘#username’).val();
if(username == “” || username.length < 4){
$(‘#username’).css(‘border’, ‘3px #CCC solid’);
$(‘#tick’).hide();
}else{
jQuery.ajax({
type: “POST”,
url: “kontrol.php”,
data: ‘username=’+ username,
cache: false,
success: function(response){
if(response == 1){
$(‘#username’).css(‘border’, ‘3px #C33 solid’);
$(‘#tick’).hide();
$(‘#cross’).fadeIn();
}else{
$(‘#username’).css(‘border’, ‘3px #090 solid’);
$(‘#cross’).hide();
$(‘#tick’).fadeIn();
}
}
});
}
}
kontrol.php
<?php
include(“databaseconfig.php”);//database bağlantınız
$connector = new DbConnector();
$username = trim(strtolower($_POST[‘username’]));
$username = mysql_escape_string($username);
$sql = “SELECT username FROM usernameCheck WHERE username = ‘$username’ LIMIT 1”;
$result = mysql_db_query($databaseadi,$sql,$databasebaglantiniz);
$num = mysql_num_rows($result);
echo $num;
mysql_close();
?>
html sayfası
<style>
#username{
padding:3px;
font-size:18px;
border:3px #CCC solid;
}
#tick{display:none}
#cross{display:none}
</style>
Username:<input name=”username” id=”username” type=”text” />
<img id=”tick” src=”tick.png” width=”16″ height=”16″/>
<img id=”cross” src=”cross.png” width=”16″ height=”16″/>