<?php session_start();
	if($_SESSION){
		$_SESSION['user_details']['fname']
?>

<html>
<head>
	<title>Customer_Details</title>
	<style type="text/css">
		
		  <link rel="stylesheet" type="text/css" href="styles.css">
  <style type="text/css">
    /* Made with love by Mutiullah Samim*/

@import url('https://fonts.googleapis.com/css?family=Numans');

html,body{

background-size: cover;
background-repeat: no-repeat;

 height:2000px;
font-family: 'Numans', sans-serif;
}
	</style>
</head>
<body style="background-color: #5499C7;">
 <?php include 'Customer.php';?><br><br>
<div class="container" >
  <?php
  error_reporting(0);
     $conn = new mysqli("localhost","root","","event");
     $CID= $_SESSION['user_details']['id'];
     $username= $_SESSION['user_details']['username'];
     $query="SELECT * FROM signup where id=$CID  ";
     $data=mysqli_query($conn,$query);
     $total =mysqli_fetch_assoc($data);
     
     
     
     
      ?>

  <form action="" method="post">
  	 <center>

  	   <h3  class="text-red" style="text-align: center;color:#8B0000 ;font-family:Monotype Corsiva;font-size: 40px;"><b>Details </b></h3>
          <div class="form-group row col-lg-8">
   
    <input type="hidden" id="id" name="id" class="form-control"  value="<?php echo $total['id']?>"  placeholder="" readonly="" required>
    <h5 id="emailcheck"></h5>
    
  </div>
  			<div class="form-group row col-lg-8">
   <label style="font-size: 20px; color: black "><b>UserName:</b> </label>
    <input type="text" id="username" name="username" class="form-control"  value="<?php echo $total['username']?>"  placeholder=""  required>
    <h5 id="emailcheck"></h5>
    
  </div>
 
  		 <div class="form-row col-lg-8">
	
		<div class="col form-group">
			<label style="font-size: 20px; color: black "><b>First name</b> </label>   
		  	<input type="text" id="fname" name="fname" class="form-control"  value="<?php echo $total['fname']?>"" placeholder="" required>
		  	<h5 id="fnamecheck"></h5>
		</div> <!-- form-group end.// -->
		<div class="col form-group">
			<label style="font-size: 20px; color: black "><b>Last name</b></label>
		  	<input type="text" id="lname" name="lname" class="form-control" value="<?php echo $total['lname']?>" placeholder=" " required>
		  	<h5 id="lnamecheck"></h5>
		</div> <!-- form-group end.// -->
	</div> <!-- form-row end.// -->
	<div class="form-group row col-lg-8">
		<label style="font-size: 20px; color: black "><b>Email:</b></label>
		<input type="email" id="email" name="email" class="form-control"  value="<?php echo $total['email']?>" placeholder="" required>
		<h5 id="emailcheck"></h5>
		
	</div> 
          <div class="form-group row col-lg-8">
             <label for="Address"  style="font-size: 20px; color: black "><b>Address:</b></label>
          <input type="text"  class="form-control" name="address" placeholder="Address"  value="<?php echo $total['address']?>" autocomplete="off" required>
        
          </div>  
          <div class="form-group row col-lg-8">
             <label for="gender"  style="font-size: 20px; color: black "><b>  Gender:</b></label>
          <input type="text" class="form-control" name="gender"  value=" <?php echo $total['gender']?>"  autocomplete="off" required>
        
          </div>
           <div class="form-group row col-lg-8">
             <label for="phone"  style="font-size: 20px; color: black "><b> phone No:</b></label>
          <input type="text" class="form-control" name="phone"  value=" <?php echo $total['phone']?>"  autocomplete="off" required>
        
          </div>
           <div class="form-group row col-lg-8">
             <label for="City"  style="font-size: 20px; color: black "><b>city:</b></label>
          <input type="text" name="city" class="form-control" placeholder="City" value=" <?php echo $total['city']?>" autocomplete="off" required>
        
          </div>
          <div class="form-group row col-lg-8">
             <label for="country"  style="font-size: 20px; color: black "><b>country:</b></label>
          <input type="text" name="country" class="form-control" placeholder="country" value=" <?php echo $total['country']?>" autocomplete="off" required>
        
          </div>
          	</center>


          <center>
    <button type="submit" class="btn btn-primary" name="update" value="update" style="text-align: center; font-size: 20px">Update</button>

    
</center>
  </form>
</div>



<?php
	}
	else{
		echo "you cant directly access the page without the session running.";
	}
	
?>

<?php
if (isset($_POST['update'])) 
   {
     $id = ($_POST['id']);
    $fname = ($_POST['fname']);
  $lname = ($_POST['lname']);
  $email = ($_POST['email']);
  $address = ($_POST['address']);
  $phone = ($_POST['phone']);
  $gender = ($_POST['gender']);
  $city = ($_POST['city']);
  $country = ($_POST['country']);  
  $username = ($_POST['username']);
  $password = ($_POST['password']);



   $conn = new mysqli("localhost","root","","event");
  $query ="Update signup set  fname='".$fname."',lname='".$lname."',email='". $email."', address='". $address."', phone='". $phone."', gender='".$gender."', city='".$city."', country='".$country."',username='".$username."',password='".$password."' where id='".$id."'";
 $data=mysqli_query($conn,$query);

  //echo "the data :".$data;  
  if ($data) {
    //echo "the data".$data;
   echo "<script>window.top.location='http://localhost/event_managment_system/wedding_plarners.php';</script>";
  } else {
    echo "Record Not Updated";
  }
  }else{
	echo "<font color='blue'>click on Update button to save the changes";
}

?>
</body>
</html>