AJAX PHP FORM issue

Hi all i am having an issue with an ajax php form im creating where im wanting my form to insert into database using ajax when i do this i get no response not sure what i am doing wrong

My code is


<?php
include("functions.php");
?>
<script type="text/javascript">
(document).ready(function(){  
$("#submit").submit(function(){  
 $.post("post.php",  
     $("#submit").serialize(),  
     function(data)
	 {  
      alert(data);  
     }  
  );  
  });  
});  
</script>
<?PHP 
<form method="post" id="submit" onsubmit="return false;">
                    <br/>
                    	<table style="background-color:#FFF; margin-left:15px">
                        	<tr>
                            	<th>Day Selected</th>
                                <th><?php echo "".$Day."&nbsp;Of ".$month."&nbsp;".$year."";  ?></th>
                            </tr>
                            <tr>
                            	<th>First Name</th>
                                <th><input type="text" name="fname" /></th>
                            </tr>
                        	<tr>
                            	<th>Last Name</th>
                                <th><input type="text" name="lname" /></th>
                            </tr>
                        	<tr>
                            	<th>Address</th>
                                <th><input type="text" name="addy" /></th>
                            </tr>
                        	<tr>
                            	<th>Country</th>
                                <th><input type="text" name="country" /></th>
                            </tr>
                        	<tr>
                            	<th>Guests</th>
                                <th><input type="text" name="Guests" /></th>
                            </tr>
                        	<tr>
                            	<th>Event Location</th>
                                <th><input type="text" name="elocation" /></th>
                            </tr>
                        	<tr>
                            	<th>Event Time</th>
                                <th><input type="text" name="etime" /></th>
                            </tr>
                        	<tr>
                            	<th>Home Phone</th>
                                <th><input type="text" name="hphone" /></th>
                            </tr>
                        	<tr>
                            	<th>Mobile Phone</th>
                                <th><input type="text" name="mphone" /></th>
                            </tr>
                            <tr>
                            	<th colspan="2"><input type="submit" value="Create Booking"/></th>
                            </tr>
                            <tr>
                            	<th colspan="2" id="sucess"><?php
								$success = TRUE;
								if ($success)
									$message = 'Yay! Everything went well!';
								else
									$message = 'Doh! Something happened';
								
								// If this is an AJAX call, echo out a JSON object for Javascript
								if ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
								  $json = array(
											  'success' => $success,
											  'message' => $message,
											  'server'  => $_SERVER
										  );
								
								  echo json_encode($json);
								
								// Else, just display the message on a new page
								} else {
								  echo 'Page was submitted...';
								  echo $message;
								}
								 ?></th>
                            </tr>
                        </table>
                    </form>
					<?

The processed php code is


$fname = $_GET['fname'];
echo $fname;
$lname = $_GET['lname'];
$addy = $_GET['addy'];
$country = $_GET['country'];
$Guests = $_GET['Guests'];
$elocation = $_GET['elocation'];
$etime = $_GET['etime'];
$hphone = $_GET['hphone'];
$mphone = $_GET['mphone'];
include("dbconnect.php");
if($fname == "")
	{
		$return['error'] = true;
		$return['msg'] = '';
	}
	else
	{
		if($lname == "")
		{
			$return['error'] = true;
			$return['msg'] = 'You did not enter your Last Name.';
		}
		else
		{
			//
			if($addy == "")
			{
				$return['error'] = true;
				$return['msg'] = 'You did not enter your Address.';
			}
			else
			{
				//
				if($country == "")
				{
					$return['error'] = true;
					$return['msg'] = 'You did not enter your Country.';
				}
				else
				{
					//
					if($Guests == "")
					{
							$return['error'] = true;
							$return['msg'] = 'You did not enter how many guests you will be having at the event.';
					}
					else
					{
						//
						if($elocation == "")
						{
							$return['error'] = true;
							$return['msg'] = 'You did not enter the location of the event';
						}
						else
						{
							//
							if($etime == "")
							{
								$return['error'] = true;
								$return['msg'] = 'You did not enter the times of the event.';
							}
							else
							{
								//
								if($hphone == "")
								{
									$return['error'] = true;
									$return['msg'] = 'You did not enter your LandLine Number.';
								}
								else
								{
									//
									if($mphone == "")
									{
										$return['error'] = true;
										$return['msg'] = 'You did not enter your Mobile Phone Number.';
									}
									else
									{
										include("dbconnect.php");
										$r="insert into Booking values('','$fname','$lname','$addy','$elocation','$Guests','$hphone','$mphone','$country','$etime')";
										$rs=mysqli_query($con,$r);
										if(!$rs)
										{
											$return['error'] = true;
											$return['msg'] = 'Cant Connect to Database';
											echo "Cant Connect to Database";	
										}
										else
										{
											$return['error'] = false;
											echo "Booking Made we will be in touch in couple of days";
										}
									}
									//
								}
								//
							}
							//
						}
						//
					}
					//
				}
				//
			}
			//
		}
	}

Is the above correct or not?

i tried to do a simple response back saying either success or fail message but nothing what am i doing wrong?

Thanks,William

Hi William

this line:


[COLOR=#000000](document).ready(function(){  
[/COLOR]


should be


[COLOR=#000000]$(document).ready(function(){  
[/COLOR]



then this line:


$.post("post.php",

tells the jQuery that you are POSTing the data but on your receiving page you are assigning the data from $_GET

ie:


$fname = $_GET['fname'];

should be


$fname = $_POST['fname'];
//etc for the other variables