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

	
	
	$BusNo = htmlspecialchars(trim($_POST['BusNo']));
	$TelephoneNo = htmlspecialchars(trim($_POST['TelephoneNo']));
	$RegNo = htmlspecialchars(trim($_POST['RegNo']));
	$RouteNo  = htmlspecialchars(trim($_POST['RouteNo']));
	$RouteName=htmlspecialchars(trim($_POST['RouteName']));
		$ans="select BusNumber from bus where BusNumber=$BusNo";
$ans2="select RouteNumber from bus where RouteNumber=$RouteNo";
$ans3="select RouteName  from bus where RouteName=$RouteName";
    if(mysql_num_rows(mysql_query($ans))>0)
      {
	   echo "yes"; //Bus Number all ready exists
	   //exit();
	   }
	else if(mysql_num_rows(mysql_query($ans2))>0)
      {
	   echo "yes"; //Bus Number all ready exists
	   //exit();
	   }	   
	  else if(mysql_num_rows(mysql_query($ans3))>0)
      {
	   echo "yes"; //Bus Number all ready exists
	  // exit();
	   }
		else
		{
		echo "no"; //New Bus details
		//now set the session from here if needed
		//$_SESSION['u_name']=$user_name; 
	$addClient  = "INSERT INTO bus(BusNumber,ContactNumber,RegistrationNumber,RouteNumber,RouteName) VALUES ('$BusNo','$TelephoneNo','$RegNo','$RouteNo','$RouteName')";
    mysql_query($addClient) or die(mysql_error());}
	


?>