<?php
        // where is your config file stored?
	include ("config.php");

	$Admission_No = htmlspecialchars(trim($_POST['AdmissionNo']));
	$Name = htmlspecialchars(trim($_POST['Name']));
	$Gender = htmlspecialchars(trim($_POST['Gender']));
	$Boarding_Point  = htmlspecialchars(trim($_POST['country']));
	$Telephone_No = htmlspecialchars(trim($_POST['TelephoneNo']));
	$Course  = htmlspecialchars(trim($_POST['Course']));
	$Semester = htmlspecialchars(trim($_POST['Semester']));
	$Bus_No= htmlspecialchars(trim($_POST['country_ID']));
	
	$checkbusquer='select BusNumber from stop where StopName="'.$Boarding_Point.'"';
	
	$ans=mysql_query($checkbusquer);
	$res=mysql_fetch_array($ans);
	if(mysql_num_rows($ans)<=0)
	{
	  echo "nobus";
	  exit();
	} 
	else
	{
		$Bus_No=$res['BusNumber'];
    } 
				   $ans="select AdmissionNo from student where AdmissionNo=$Admission_No";
					if(mysql_num_rows(mysql_query($ans))>0)
					  {
					   echo "yes"; //Admission Number all ready exists
					   }
					else
						{
						echo "no"; //New student details
						//now set the session from here if needed
						//$_SESSION['u_name']=$user_name; 
						$addClient  = "INSERT INTO student(Name,AdmissionNo,Gender,TeleNo,Batch,Semester,BusNumber,StopName) VALUES ('$Name','$Admission_No','$Gender','$Telephone_No','$Course','$Semester','$Bus_No','$Boarding_Point')";
					mysql_query($addClient) or die(mysql_error());	
					}

	
	?>