<?php
	session_start();
	include"../../connect/db.php"; 
 ?>  
<?php
	if( $_POST['user'] ){
		$chap = $_POST['user'] ;

		$sql = mysqli_query($con, "SELECT * FROM users WHERE email = '$chap' ");

		while( $row = mysqli_fetch_assoc($sql) ){

			if( $row['gender'] == "Male"  ){
				$gender =  
				'
	                <option selected="selcted" value="Male">Male</option>
	                <option value="Female">Female</option>
	            ';    				
			}
			else{
				$gender = 
				'
	                <option value="Male">Male</option>
	                <option selected="selcted" value="Female">Female</option>
				';
			}

			if( $row['account_type'] == "Savings Account" ){
				$acctype = 
				'
	                <option selected="selcted" value="Savings Account">Savings Account</option>
	                <option value="Current Account">Current Account</option>
	                <option value="Checking Account">Checking Account</option>
	                <option value="Fixed Deposit Account">Fixed Deposit Account</option>
	                <option value="Off Shore Account">Off Shore Account</option>				
				';
			}
			else if( $row['account_type'] == "Current Account" ){
				$acctype = 
				'
	                <option value="Savings Account">Savings Account</option>
	                <option selected="selcted" value="Current Account">Current Account</option>
	                <option value="Checking Account">Checking Account</option>
	                <option value="Fixed Deposit Account">Fixed Deposit Account</option>
	                <option value="Off Shore Account">Off Shore Account</option>				
				';				
			}
			else if( $row['account_type'] == "Checking Account" ){
				$acctype = 
				'
	                <option value="Savings Account">Savings Account</option>
	                <optionvalue="Current Account">Current Account</option>
	                <option selected="selcted" value="Checking Account">Checking Account</option>
	                <option value="Fixed Deposit Account">Fixed Deposit Account</option>
	                <option value="Off Shore Account">Off Shore Account</option>				
				';					
			}
			else if( $row['account_type'] == "Fixed Deposit Account" ){
				$acctype = 
				'
	                <option value="Savings Account">Savings Account</option>
	                <optionvalue="Current Account">Current Account</option>
	                <option value="Checking Account">Checking Account</option>
	                <option selected="selcted" value="Fixed Deposit Account">Fixed Deposit Account</option>
	                <option value="Off Shore Account">Off Shore Account</option>			
				';					
			}
			else if( $row['account_type'] == "Off Shore Account" ){
				$acctype = 
				'
	                <option value="Savings Account">Savings Account</option>
	                <optionvalue="Current Account">Current Account</option>
	                <option value="Checking Account">Checking Account</option>
	                <option value="Fixed Deposit Account">Fixed Deposit Account</option>
	                <option selected="selcted" value="Off Shore Account">Off Shore Account</option>				
				';					
			}

			if( $row['currency'] == "$" ){
				$currency = 
				'
                    <option value="$">$ US DOLLARS ($)</option>
                    <option value="£"> £ GREAT BRITISH POUNDS (GBP)</option>
                    <option value="¥">¥ Chinese Yuan (CNY)  </option>
                    <option value="€">€ Euros </option>				
				';
			}
			else if( $row['currency'] == "£" ){
				$currency = 
				'
                    <option value="$">$ US DOLLARS ($)</option>
                    <option selected="selcted" value="£"> £ GREAT BRITISH POUNDS (GBP)</option>
                    <option value="¥">¥ Chinese Yuan (CNY)  </option>
                    <option value="€">€ Euros </option>				
				';				
			}
			else if( $row['currency'] == "¥" ){
				$currency = 
				'
                    <option value="$">$ US DOLLARS ($)</option>
                    <option value="£"> £ GREAT BRITISH POUNDS (GBP)</option>
                    <option selected="selcted" value="¥">¥ Chinese Yuan (CNY)  </option>
                    <option value="€">€ Euros </option>				
				';				
			}
			else if( $row['currency'] == "€" ){
				$currency = 
				'
                    <option value="$">$ US DOLLARS ($)</option>
                    <option value="£"> £ GREAT BRITISH POUNDS (GBP)</option>
                    <option value="¥">¥ Chinese Yuan (CNY)  </option>
                    <option selected="selcted" value="€">€ Euros </option>				
				';				
			}

			if ( $row['status'] == "Active" ){
				$status = 
				'
                    <option selected="selcted" value="Active">Active</option>
                    <option value="Suspended">Suspended</option>
                    <option value="Terminated">Terminate</option>
				';				
			}
			else if( $row['status'] == "Suspended" ){
				$status = 
				'
                    <option value="Active">Active</option>
                    <option selected="selcted" value="Suspended">Suspended</option>
                    <option value="Terminated">Terminate</option>
				';				
			}
			else if( $row['status'] == "Terminated" ){
				$status = 
				'
                    <option value="Active">Active</option>
                    <option value="Suspended">Suspended</option>
                    <option selected="selcted" value="Terminated">Terminate</option>
				';				
			}										
			echo
			'
                <div class="login-form">
                    <form class="regForm form">
                        <div class="form-group">
                            <input class="au-input au-input--full" type="text" name="title" value="'.$row['title'].'">
                        </div>                    
                        <div class="form-group">
                            <input class="au-input au-input--full" type="text" name="f_name" value="'.$row['f_name'].'">
                        </div>
                        <div class="form-group">
                            <input class="au-input au-input--full" type="text" name="m_name" value="'.$row['m_name'].'">
                        </div>                        
                        <div class="form-group">
                            <input class="au-input au-input--full" type="text" name="l_name" value="'.$row['l_name'].'">
                        </div>
                        <div class="form-group">
                        	<label for="phone">Phone</label>
                            <input class="au-input au-input--full" type="text" name="phone" value="'.$row['phone'].'">
                        </div>
                        <div class="form-group">
                        	<label for="acct_num">Account Num</label>
                            <input class="au-input au-input--full" type="text" name="acct_num" value="'.$row['account_num'].'">
                        </div>                                                                              
                        <div class="form-group">
                            <input class="au-input au-input--full" type="hidden" name="email"value="'.$row['email'].'" >
                        </div>
                        <div class="form-group">
                        	<label for="amount">Balance</label>
                            <input class="au-input au-input--full" type="text" name="amount" value="'.$row['amount'].'" >
                        </div>                        
                        <div class="form-group">
                        	<label for="pword">Password</label>
                            <input class="au-input au-input--full" type="text" name="pword" value="'.$row['password'].'">
                        </div>
                        <div class="form-group">
                            <input class="au-input au-input--full" type="date" name="d_o_b" value="'.$row['d_o_b'].'">
                        </div>   
                        <div class="form-group">
                            <select id="gender" name="gender" class="au-input au-input--full">
                            	'.$gender.'
                            </select>
                        </div>
                        <div class="form-group">
                            <textarea rows="4" class="au-input au-input--full" name="address" id="address" >'.$row['address'].'</textarea>
                        </div>
                        <div class="form-group">
                            <input class="au-input au-input--full" type="text" name="city" value="'.$row['city'].'">
                        </div>
                        <div class="form-group">
                            <input class="au-input au-input--full" type="text" name="state" value="'.$row['state'].'">
                        </div>
                        <div class="form-group">
                        	<label for="zip_code">Zip Code</label>
                            <input class="au-input au-input--full" type="text" name="zip_code" value="'.$row['zip_code'].'">
                        </div>
                        <div class="form-group">
                        	<select id="acctype" name="acctype" class="au-input au-input--full">
                        		'.$acctype.'
                        	</select>
                        </div>
                        <div class="form-group"> 
                        	<select id="currency" name="currency" class="au-input au-input--full">
								'.$currency.'
							</select>            
                        </div>
                        <div class="form-group">
                        	<label for="pin">Pin</label>
                            <input class="au-input au-input--full" type="pin" name="pin" value="'.$row['pin'].'">
                        </div> 
                        <div class="form-group"> 
                        	<select id="status" name="status" class="au-input au-input--full">
								'.$status.'
							</select>            
                        </div>
                        <span onclick="updateProfile()" class="au-btn au-btn--block au-btn--green m-b-20">Update</span>
                    </form>    
                </div>
			';
		}
	}
	else{

		echo "error";
	}
?>