<?php

require_once("headUserAcc.php");

if(isset($_POST["submit"]))
{
   //require("buda_connect.php");
  // $con = new connect_class();

   
     $category=$_POST['category'];

     $email=$_POST['email']; 

     $phoneno=$_POST['phoneno']; 

     $pobox=$_POST['pobox'];

     $street=$_POST['street'];

     $ward=$_POST['ward'];

     $district=$_POST['district'];

     $region=$_POST['region'];

     $country=$_POST['country'];

     $popularDistination=$_POST['popularDistination'];

     $hname=$_POST['hname'];
     $ownerid=$ownID=$_POST['owniD']; 
     $admin=$_POST['admin']; 
   
     
   if(!$con->vCategory($category)|| !$con->vPopularDistination($popularDistination) || !$con->vStreet($street) || !$con->vHname($hname) || !$con->vWard($ward) || !$con->vDistrict($district) || !$con->vRegion($region) || !$con->vCountry($country) || !$con->vPhoneno($phoneno) || !$con->vEmail($email))
         
      {
        echo "<center><div><sup>";
      echo $con->eCountry($country)."<p/>";
      echo $con->eRegion($region)."<p/>";
      echo $con->eDistrict($district)."<p/>";
      echo $con->eStreet($street)."<p/>";
      echo $con->ePhoneno($phoneno)."<p/>";
      echo $con->eHname($hname)."<p/>";
      echo "</div></center></sup>"; 
      echo $con->eCategory($category)."<p/>";
        require("restingHouseRegForm.php");
      }
   else
      {
	     if(isset($_POST['admin']) && isset($_POST['owniD']))
           {
           $ce= $con->checkIdOfUserIfExist($ownerid);//->fetch();
            if ($ce->rowCount()>0) {
              $hnm=Date("Ymdhis");
               print_r($con->addHotel($hnm,$ownerid,$hname,$category,$phoneno, $email,$pobox,$district,$country, $street ,$ward, $region,$popularDistination));   
                 $ownID="";
                
                 $email=""; 

                 $phoneno=""; 

                 $pobox="";

                 $street="";

                 $ward="";

                 $district="";

                 $region="";

                 $country="";

                 $popularDistination="";

                 $hname="";

                 $category="";

                 require("restingHouseRegForm.php");
            }
            else{
              echo "<center><sup>Invalid user id!..</sup></center>";
               require("restingHouseRegForm.php");
            }
 
       //require("successEditHotelProfileForm.php");
           }
      }

 
     }
else 
     {
      $ownID="";
      $email=""; 

     $phoneno=""; 

     $pobox="";

     $street="";

     $ward="";

     $district="";

     $region="";

     $country="";

     $popularDistination="";

     $hname="";
     $category="";
      require("restingHouseRegForm.php");
      
	//echo "Error occured when saving data!..";
     }

?>