Location: PHPKode > scripts > License management script > ajax.php
<?php
/*
=============================================================
Script Name                : license management class
Auther                    : Payam khaninajad
Contact                   : hide@address.com
Follow me on twitter      : http://twitter.com/khaninajad
Location                  : Iran-Azarbayjan 
Year                      : 2010-12-19
Version                   : 1.0
=============================================================
this page used to show how we can check for license validation process with ajax/jquery .
this is ajax request page 
*/
$database="licence";//mysql database name
$username="root"; // mysql database username
$password="passwd";// mysql password
$host="localhost";// mysql hostname

mysql_connect($host,$username,$password)or die("err in database".mysql_error());// connection to database
mysql_select_db($database);// database selection

require_once("licence.inc.php");// load class
$mylicence=new licence;

if(isset($_GET['serial']) && isset($_GET['id'])) // please pay attention to sql injection 
{
	$id=htmlspecialchars($_GET['id']);
	$serial=$_GET['serial'];
	if($mylicence->validate_my_licence($id,$serial)==0)// check for serial 
	{
	   // check for registered version
		$sql="SELECT COUNT(*) FROM `activation` WHERE `activation_username`='".$id."' and `activation_serial`='".$serial."'";  
		$sql=mysql_query($sql)or die("err".mysql_error());
		$res=mysql_fetch_row($sql);
		if($res[0]==1) 
		{
			echo 1;// it is registered
		}
		else
		{
			echo 2;
            // serial and user name isn't true or not registered user, so it is nulled version 
            // you can save server ip or host name for report nulled version
                    
		}
	}
	else
	{
	echo 0;// problem happened in server
	}
}else{
?>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"></head>
<body>
<script type="text/javascript">
$('p[id=closepanel]').hide();
$('#validate').click(function() {
    // you can send request to remote page
  $.get("ajax.php", { serial: $('#serial').val(), id: $('#id').val() },
   function(data){
     if(data==1) 
	 {
	 $('div[id=res]').html("Valid");// response message
      $('p[id=closepanel]').show();//show remove link 
      $('div[id=all]').hide();// hide registration link
	 }else if(data==2){
	 $('div[id=res]').html("You are Using nulled version. please Buy or register ur app");
	 }else if(data==0){
	 $('div[id=res]').html("We Got problem");
     }
	 
	 
   });
});
</script>
<div id="res"></div>
<p id="closepanel"><a href="#" class="closeDOMWindow">close window</a></p>
<table width="200" border="0">
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>ID :</td>
    <td><input type="text" id="id" /></td>
  </tr>
  <tr>
    <td>Serial :</td>
    <td><input type="text" id="serial" /></td>
  </tr>
</table>
<input type="button" id="validate" value="Validate" />
</body></html>

<?php
}
?>
Return current item: License management script