Include library
ajax_check_user.php
<script src="js/jquery.min.js"></script>   
<script src="js/jquery.validate.js"></script>
<?php$_SESSION['code']=rand(1000,2000);?> 
<form name="form-signup" id="form-signup" method="post" >
<table width="50%">
  <tr>
    <td>Name</td>
    <td><input type="text" name="name" id="name" class="change"></td>
  </tr>
  <tr>
    <td>Email</td>
    <td><input type="text" name="email" id="email" class="change"></td>
  </tr>
  <tr>
    <td>Username</td>
    <td><input type="text" name="username" id="username" class="change"></td>
  </tr>
  <tr>
    <td>Password</td>
    <td><input type="text" name="password" id="password"class="change"></td>
  </tr>
  <tr>
    <td>Re-Password</td>
    <td><input type="text" name="con_password" id="con_password" class="change"></td>
  </tr>
  <tr>
    <td>Code</td>
    <td><?php echo $_SESSION['code'];?><input type="text" name="code" id="code" ></td>
  </tr>
  <tr>
    <td> </td>
    <td><input type="submit" name="submit" id="submit" value="Sign Up"></td>
  </tr>
  
</table>
</form>
<script type="application/javascript" language="javascript">
jQuery("#form-signup").validate(
{   
        errorElement:'div',
        rules:{
            name:{
                required: true          
            },
            email:{
                required: true,
                email:true,
                remote:'include/ajax_check_user.php'
            },
            username:{
                required: true,
                remote:'include/ajax_check_user.php'
            },
            password:{
                required: true,
                minlength:8,
                maxlength:14
            },
            con_password:{
                equalTo:"#password"
            },
            code:{
                required: true,
                remote:'include/ajax_check_user.php'
            }
        },
        submitHandler: function (form) 
        {
             jQuery.ajax({
                 type: "POST",
                 url: "include/ajax_login.php?registration=1",
                 data: jQuery(form).serialize(),
                 success: function () 
                 {
                    
                 }
             });
             return false; // required to block normal submit since you used ajax
        }
});
</script>
ajax_check_user.php
<?php 
include('class.crud.php'); 
$result = 'true';
if(trim(@$_GET['username'])!= "")
{
    $order = "SELECT user_id  FROM tbl_user where user_id='".trim($_GET['username'])."'";
    $result_rel = mysql_query($order);
    $row = @mysql_num_rows($result_rel);
        if($row=='1')
        {
            $result='false';
        }   
}
if(trim(@$_GET['email'])!= "")
{
    $order = "SELECT email FROM tbl_user where email='".trim($_GET['email'])."'";
    $result_rel = mysql_query($order);
    $row = @mysql_num_rows($result_rel);
        if($row=='1')
        {
            $result='false';
        }   
}
if(trim(@$_GET['code'])!= "")
{
    
        if($_SESSION['code']!=$_GET['code'])
        {
            $result='false';
        }   
}
echo $result;
?>
ajax_login.php
<?php 
include('class.crud.php'); 
if(@$_GET['registration']==1)
{
    print_r($_POST);
}
?>
super.....
ReplyDelete