PHP AJax Login Issue

Hi all i am having an issue with my Ajax Login code i have successfully done it with my Ajax Form submission but not sure why i cant do it with a login

This is what i have atm…


<?php
if(!(isset($_SESSION['user'])))
{
	?>
	<script type="text/javascript">
	$(document).ready(function(){  
	$("#submit").submit(function(){  
	 $.post("alogin.php",  
		 $("#submit").serialize(),  
		 function(data)
		 {  
		  //alert(data);
		  $("#result").html(data); 
		 }  
	  );  
	  });  
	});  
	</script>
	<form method="post" id="submit" onsubmit="return false;">
	<table>
    	<tr>
        	<th colspan="2">Login to admin area</th>
        </tr>
    	<tr>
        	<th>Username:</th>
        	<th><input type="text" name="username" /></th>
        </tr>
    	<tr>
    	<tr>
        	<th>Password</th>
        	<th><input type="password" name="password" /></th>
        </tr>
        	<th colspan="2"><input type="submit" value="Login"/></th>
        </tr>
    </table>
    <div id="result"></div>
	</form><?php 	
}
else
{
	?>
	<fieldset>
            	<legend>Events Section</legend>
            </fieldset>
            <br/>
        	<fieldset>
            	<legend>Manage DJ Bookings</legend>
            </fieldset>
	<?	
}

That part seems fien but the part that bothers me is this next part


session_start();
error_reporting(E_ALL);
include("dbconnect.php");
$username = mysqli_real_escape_string($con,stripslashes(trim($_POST['username'])));
				$password = mysqli_real_escape_string($con,stripslashes(trim($_POST['password'])));
				$cQuery="SELECT * FROM admin WHERE username='".$username."' AND Password='".$password."'";
				$con;
				$rs=mysqli_query($con,$cQuery);
				if(!$rs)
				{
					echo "Unable to excute the query:".mysqli_error($con);
				}
				else
				{
					$count=$rs->num_rows;
					if($count>0)
					{
						//
						while($data=mysqli_fetch_assoc($rs))
						{
							//
							if($data['password']=$password)
							{
								//For Rembmer me
								$_SESSION['user']=$username;
								//
							}
							else
							{
								$msg_pass="Wrong Password,Please Try again<br>\
";
							}
							//
						}
						//
					}
					else
					{
						$msg_user="Wrong Username,Please Try again<br>\
";
					}
				}

So what am i doing wrong as the session not being set i get no errors and when the password is redirected i want the login information to be checked it correct refresh page to see if session is valid and display members page.

but the above doesnt work for some reason what am i doing wrong can any1 help me point this out?

Thanks,William