 
<?php
require_once("head2Alt.php");

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

  $post=$_POST['post'];


 $accountId =$_POST['owniD']; 


////CODE FOR SAVING CHANGES GOES HERE///

  if($post=="Save changes")
  {
 
  $fname= $_POST['fname'];

   $mname=$_POST['mname'];

   $lname=$_POST['lname']; 

   $email=$_POST['email']; 

   $phoneno=$_POST['phoneno']; 

   $pobox=$_POST['pobox'];

   $street=$_POST['street'];

   $ward=$_POST['ward'];

   $district=$_POST['district'];

   $region=$_POST['region'];

   $country=$_POST['country'];

   $gender=$_POST['gender'];

   $dob=$_POST['dob'];

   $occupation=$_POST['occupation'];

  if(!$con->vFname($fname) || !$con->vMname($mname) || !$con->vLname($lname) || !$con->vStreet($street) || !$con->vWard($ward) || !$con->vDistrict($district) || !$con->vRegion($region) || !$con->vCountry($country) || !$con->vPhoneno($phoneno) || !$con->vEmail($email) || !$con->vGender($gender) || !$con->vDate($dob) || !$con->vOccupation($occupation))
          
          {
                //require_once"myAccountProfileAfterSuccessPost.php";
            ?>
  <center>
  <div>
  <sup>
    <?php  
    
   echo  $con->eFname($fname); 
   echo  $con->eMname($mname);
   echo  $con->eLname($lname);
   echo  $con->eStreet($street);
   echo  $con->eWard($ward);
   echo  $con->eDistrict($district);
   echo  $con->eRegion($region);
   echo  $con->eCountry($country);
   echo  $con->ePhoneno($phoneno);
   echo  $con->eEmail($email);
   echo  $con->eGender($gender);
   echo  $con->eDate($dob);
   echo  $con->eOccupation($occupation);

     ?>
</sup>
</div>
</center>

<?php

          }
 
  else    {
    ?>
  <center>
  <font size="2" color="blue">
  <?php
               echo $afRo=$con->updateMyAccount($phoneno,$accountId,$fname, $mname, $lname, $gender, $occupation, $email,$pobox,$district,$country, $street ,$ward, $region, $dob);
      ?>
 </font>
 </center>
 <?php
               require_once"myAccountProfileAfterPost.php";

          
  }

  }
//////

  /////////////CODE FOR SAVING CHANGES ENDS/////////////
  /////////////

  if($post=="Edit profile info"){
 
    
   
              if($con->myProfileInfo($accountId)->rowCount()>0)
               {
                  $ED=$con->myProfileInfo($accountId);
                  $info=$ED->fetch();
             
?>

<center> 
 
  <!--NEW USER REGISTRATION FORM, DISPLAYED BY DEFAULTS IN PAGE LOAD-->


<fieldset id="alt_new_user_reg_form">
<label id="reg_form_tile_label">Make changes to your account info hear:-</label></p/>
<i>Please edit particular detail you want to change hear:-</i>
<form name="new_user_registration" id="new_user_registration" action="editMyAccountProfilePro.php"  method="post">

<table border="0" id="reg_form_table">

<tr>                      <!--CARRY HOTEL ID AND ROOM ID-->

        <input class="hi" type="text" name="owniD"  value="<?php echo $accountId;?>">
  
 

        

                                                      <!--USERS NAME-->





<td  id="reg_form_table_cell" valign="bottom"><label id="main_label">Name:</label></td></tr>

 
<tr><td height="40px" valign="top">    <label id="mini_label">First Name<sup>*</sup></label> <br/> <sup id="nf"></sup>   </td>  

<td height="40px" valign="top"> <label id="mini_label">Middle Name </label>   <br><sup id="mn"></sup>   </td>


<td height="40px" valign="top"><label id="mini_label">Last Name<sup>*</sup></label><br><sup id="ln"></sup>

        </td></tr>


    <tr ><td id="reg_form_table_cell">
    
        <input type="text" disabled="true" name="fname" id="fname" class="prof_info" value="<?php echo $info['fname'];?>"  /> 
       
        </td>
        <td id="reg_form_table_cell">
        

         <input type="text" disabled="true" name="mname" id="mname" class="prof_info" value="<?php echo $info['mname'];?>" /><br/>
     
         
         </td>
     

    <td id="reg_form_table_cell">

    
        <input type="text" disabled="true" name="lname" id="lname" class="prof_info" value="<?php echo $info['lname'];?>" /><br/>
        
    </td></tr>
<tr>





                                                                             
                                                                             <!----CONTACT ADDRESS-->




<tr> <td colspan="3" id="reg_form_table_cell" valign="bottom">

<label id="main_label"  >Contact Address:</label>
 
</td>
</tr>


<tr><td height="40px" valign="top"> <label>E-mail<sup>*</sup></label><br><sup id="em"></sup></td>


<td height="40px" valign="top"><label id="mini_label">Phone Number1<sup>*</sup></label>
<br><sup id="p"></sup></td>


<td height="40px" valign="top"> <label id="mini_label">Phone Number2<sup>optional</sup></label></td></tr>
 

<tr><td id="reg_form_table_cell">
    
    
     <input type="email" disabled="true" name="email" id="email" class="prof_info" value="<?php echo $info['email'];?>" /><br/>
    
    
    </td>
     <td id="reg_form_table_cell">
     
     <input type="text"  disabled="true" name="phoneno" id="phoneno" class="prof_info" value="<?php echo $info['phoneno'];?>" /><br/>
     
     </td>

      <td>
     
     <input type="text" name="phoneno2" id="phoneno2" class="prof_info" /><br/>
    

     </td>
</tr>






                               <!---USERS PLACE OF BIRTH-->


<tr>
<td colspan="3" id="reg_form_table_cell" valign="bottom">

<label id="main_label">Place of resident:</label> 
  
  </td>

</tr>
<tr>
   <td height="40px" valign="top"> <label id="mini_label">P.o.box<sup>optional</sup></label><br/></td>

   <td height="40px" valign="top">  <label id="mini_label">Street/Village<sup>*</sup></label><br><sup id="vs"></sup></td>

   <td height="40px" valign="top">   <label id="mini_label">Ward<sup>*</sup></label><br><sup id="w"></sup> </td>

</tr>




<tr><td id="reg_form_table_cell">

        <input type="text" name="pobox" id="pobox" class="prof_info" value="<?php echo $info['postAddress'];?>"/><br/>
       
    </td>
    <td id="reg_form_table_cell">

    
        <input type="text" name="street" id="street" class="prof_info" value="<?php echo $info['street'];?>" /><br/>
        
    </td>

    <td id="reg_form_table_cell">

    
        <input type="text" name="ward" id="ward" class="prof_info" value="<?php echo $info['ward'];?>" /><br/>
      
    </td>

    

<tr>
   <td height="40px" valign="top"> <label id="mini_label">Town/District<sup>*</sup></label> <br><sup id="ds"></sup></td>


   <td height="40px" valign="top">    <label id="mini_label">City/Region<sup>*</sup></label> <br><sup id="r"></sup></td>


   <td height="40px" valign="top"> <label id="mini_label">Country<sup>*</sup></label><br><sup id="c"></sup> </td>

</tr>



    <tr>


    <td id="reg_form_table_cell">
       
        <input type="text" name="district" id="district" class="prof_info" value="<?php echo $info['district'];?>" /><br/>
         
    </td>
    <td id="reg_form_table_cell">

   
        <input type="text" name="region" id="region" class="prof_info" value="<?php echo $info['city'];?>" /><br/>
      
    </td>

    <td id="reg_form_table_cell">

    
        <input type="text" name="country" id="country" class="prof_info" value="<?php echo $info['country'];?>" /><br/>
        
    </td>
</tr>








<!----PLACE OF BIRTH, AND PROFILE GENDER-->




<tr><td height="40px" valign="top">   <label id="main_label" >Gender<sup>*</sup></label>     <br><sup id="g"></sup></td>


<td   height="40px" valign="top"> <label id="main_label" >Date of birth<sup>*</sup>:</label> <br><sup id="ob"></sup> </td> 
 
 <td valign="bottom" id="reg_form_table_cell"> <label id="main_label">Occupation<sup>*</sup>:</label> <br><sup id="o"></sup> 
 </td>

 </tr>

 <tr>

      <td id="reg_form_table_cell">  <input name="gender" disabled="true" type="text" id="gender"  class="prof_info" value="<?php echo $info['gender'];?>"/>  
  
      <td   id="reg_form_table_cell"> 
      
      <input type="date" disabled="true" name="dob" id="dob" class="prof_info" value="<?php echo $info['dob'];?>"/> </td>
     
      <td id="reg_form_table_cell">

     <input type="text" name="occupation" id="occupation" class="prof_info" value="<?php echo $info['occupation'];?>" /><br/>
         
    </td>
</tr>

 


<tr id="">
  <td  colspan="3" align="center" id="reg_form_table_cell">
        <input type="submit"  name="post" value="Save changes"/>
  </td>
   
</tr>

 </table>
 
</form>
</fieldset>

<script>
$(document).ready(function(){

$("#new_user_registration").on('post',function(e){

var fname =document.getElementById('fname').value;
$.trim(fname);
var mname =document.getElementById('mname').value;
$.trim(mname);
var lname =document.getElementById('lname').value;
$.trim(lname);
var street =document.getElementById('street').value;
$.trim(street);
var email =document.getElementById('email').value;
$.trim(email);
var ward =document.getElementById('ward').value;
$.trim(ward);
var district =document.getElementById('district').value;
$.trim(district);
var region =document.getElementById('region').value;
$.trim(region);

var country =document.getElementById('country').value;
$.trim(country);
 
var phoneno =document.getElementById('phoneno').value;
$.trim(phoneno);
var occupation =document.getElementById('occupation').value;
$.trim(occupation);

var gender =document.getElementById('gender').value;
$.trim(gender);
  


var vN =/[\(A-Za-z)]/g;
var nV =/[a-z\s]/i;
  var j=0,k=0, g=0,i=0;

                                                         //FIRST NAME VALIDATION
if(fname=="")
{
e.preventDefault();

document.getElementById('nf').innerHTML="First name is required!..";
 } 
 else
 {

      for(i=0;i<fname.length;i++)
       {
         if(!fname[i].match(vN))
          {
             j++;

           }
        }
      
       if(j>0){
        e.preventDefault();

       
        document.getElementById('nf').innerHTML="Invalid name"; 


              }
         else{

        document.getElementById('nf').innerHTML="";

              }
   }
 
    j=0, i=0;
                                                                               ///MIDDLE NAME VALIDATION
 

if(mname==""){
e.preventDefault();

document.getElementById('mn').innerHTML="Middle name is required!..";
 }
 else{

     for(i=0;i<mname.length;i++)
       {
         if(!mname[i].match(vN))
          {
             j++;

           }
        }
      
       if(j>0){
       e.preventDefault();
 
        document.getElementById('mn').innerHTML="Invalid name"; 
              }
         else{
       

        document.getElementById('mn').innerHTML="";

              }
   }
 
    j=0, i=0;
               
 


                                                                            ///LAST NAME VALIDATION



if(lname==""){
 e.preventDefault();

document.getElementById('ln').innerHTML="Last name is required!..";
 
 
              }
 else{

     for(i=0;i<lname.length;i++)
       {
         if(!lname[i].match(vN))
          {
             j++;

           }
        }
      
       if(j>0){
        e.preventDefault();

        document.getElementById('ln').innerHTML="Invalid name"; 
              }
         else{

        document.getElementById('ln').innerHTML="";

              }
   }
 
    j=0, i=0;
               


 
                                                                            ///STREET VALIDATION
 

if(street==""){
 e.preventDefault();

document.getElementById('vs').innerHTML="Street is required!..";
 

 }
 else{

      for(i=0;i<street.length;i++)
       {
         if(!street[i].match(nV))
          {
             j++;

           }
        }
      
       if(j>0){
       e.preventDefault();
   
        document.getElementById('vs').innerHTML="Invalid name"; 
              }
         else{
 
        document.getElementById('vs').innerHTML="";

              }
   }
 
    j=0, i=0;
               
 


                                                    //EMAIL VALIDATION


 
var mail=/[\(A-Za-z)][\w.]\w+@\w+\.(net|com|edu)/;
if(email==""){
 e.preventDefault();
document.getElementById('em').innerHTML="E-mail address is required!..";
 

             }
 else{
  
         if(!email.match(mail))
          {
          
        e.preventDefault();
        document.getElementById('em').innerHTML="Invalid email"; 
              }
         else{ 
        document.getElementById('em').innerHTML="";

              }
   }
 
   
            
  


                                                                            ///WARD VALIDATION

if(ward==""){
e.preventDefault();
document.getElementById('w').innerHTML="Ward is required!..";
 

           }
  else{
 for(i=0;i<ward.length;i++)
       {
         if(!ward[i].match(nV))
          {
             j++;

           }
        }
      
       if(j>0){
        e.preventDefault();
        document.getElementById('w').innerHTML="Invalid ward name"; 
              }
         else{ 
        document.getElementById('w').innerHTML="";

              }
   }
 
    j=0, i=0;
                                                                            ///DISTRICT VALIDATION



if(district==""){
e.preventDefault();
document.getElementById('ds').innerHTML="District is required!..";
 
          }
 else{

     for(i=0;i<district.length;i++)
       {
         if(!district[i].match(nV))
          {
             j++;

           }
        }
      
       if(j>0){
        e.preventDefault();
        document.getElementById('ds').innerHTML="Invalid district name"; 
              }
         else{ 
        document.getElementById('ds').innerHTML="";

              }
   }
 
    j=0, i=0;                     


                                                                  ///REGION VALIDATION

if(region==""){
e.preventDefault();
document.getElementById('r').innerHTML="Region is required!..";
              }
 else{
 for(i=0;i<region.length;i++)
       {
         if(!region[i].match(nV))
          {
             j++;

           }
        }
      
       if(j>0){
        e.preventDefault();
        document.getElementById('r').innerHTML="Invalid region  name"; 
              }
         else{ 
        document.getElementById('r').innerHTML="";

              }
   }
 
    j=0, i=0;
                                                                ///COUNTRY VALIDATION

 
if(country==""){
e.preventDefault();
document.getElementById('c').innerHTML="Country is required!..";
 

               }
 else{

    for(i=0;i<country.length;i++)
       {
         if(!country[i].match(nV))
          {
             j++;

           }
        }
      
       if(j>0){
        e.preventDefault();
        document.getElementById('c').innerHTML="Invalid name"; 
              }
         else{ 
        document.getElementById('c').innerHTML="";

              }
   }
 
    j=0, i=0;                                                                        


     ///PHONE NUMBER VALIDATION

 var phn =/[\(0-9)]{10,12}/;
   
if(phoneno==""){
e.preventDefault();
document.getElementById('p').innerHTML="Phone is required valid one!..";
 

              }
 else{ 
       
         if(!phoneno.match(phn))
          {
             
        e.preventDefault();
        document.getElementById('p').innerHTML="Invalid phone"; 
              
          }
        
         else if(phoneno.length>12)
         {
        e.preventDefault();
        document.getElementById('p').innerHTML="Valid phone number must contain 12 digits.."; 
              

         }

         else
         {

        document.getElementById('p').innerHTML="";

        }
   }
 
    j=0, i=0; 
                                                               /// GENGER VALIDATION


 
if(  gender==""){
e.preventDefault();
document.getElementById('g').innerHTML="Gender is required!..";
 

               }
else{

document.getElementById('g').innerHTML="";
    }
  
                                                           ///OCCUPATION VALIDATION

 

if(occupation=="")
{
e.preventDefault();
document.getElementById('o').innerHTML="Occupation is required!..";
 
}
 else{

     for(i=0;i<occupation.length;i++)
       {
         if(!occupation[i].match(nV))
          {
             j++;

           }
        }
      
       if(j>0){
        e.preventDefault();
        document.getElementById('o').innerHTML="You typed occupatio with error"; 
              }
         else{

        document.getElementById('o').innerHTML="";

              }
   }
 
    j=0, i=0;  
 
 
  
}
);
}
);    
</script>
<?php
  }

  } 
}              
 
require_once('footerIn.php');
?>
