<?php
require_once '../includes/core.php';
require '../includes/connect.php';






if (loggedin()){
$profile1 = getfield('profile','users','user_id');

$user_name = getfield('username','users','user_id');
$first_name = getfield('firstname','users','user_id');
$last_name = getfield('lastname','users','user_id');
$user_id = getfield('user_id','users','user_id');
$password = getfield('password','users','user_id');

$mailuser1 = getfield2('email','alert','id');

$balance = getfield('balance','users','user_id');



$accounttype = getfield('accounttype','users','user_id');

$address = getfield('address','users','user_id');

$currency = getfield('currency','users','user_id');

$city = getfield('city','users','user_id');

$state = getfield('state','users','user_id');
$zipcode = getfield('zipcode','users','user_id');
$country = getfield('country','users','user_id');
$confirm = getfield('confirm','users','user_id');


$email = getfield('email','users','user_id');
$phone = getfield('phone','users','user_id');
$dob = getfield('dob','users','user_id');

$gender = getfield('gender','users','user_id');

$photo = getfield('photo','users','user_id');


$kinname = getfield('nextofkin','users','user_id');
$kinlastname = getfield('klastname','users','user_id');
$kinphone = getfield('nphone','users','user_id');

$kinaddress = getfield('naddress','users','user_id');

$accountno = getfield('accountno','users','user_id');
$accountname = getfield('accountname','users','user_id');
$bankname = getfield('bankname','users','user_id');




}
else
{ 
	header('Location:loginexec.php');
}
?>






<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
	<meta name="description" content="">
	<meta name="author" content="">
	<link rel="icon" type="image/png" href="../assets/img/favicon.png">

	<title>SkilledOrbit - Profile</title>

	<!-- Fonts -->
	<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,500,700&amp;subset=latin-ext" rel="stylesheet">

	<!-- CSS - REQUIRED - START -->
	<!-- Batch Icons -->
	<link rel="stylesheet" href="assets/fonts/batch-icons/css/batch-icons.css">
	<!-- Bootstrap core CSS -->
	<link rel="stylesheet" href="assets/css/bootstrap/bootstrap.min.css">
	<!-- Material Design Bootstrap -->
	<link rel="stylesheet" href="assets/css/bootstrap/mdb.min.css">
	<!-- Custom Scrollbar -->
	<link rel="stylesheet" href="assets/plugins/custom-scrollbar/jquery.mCustomScrollbar.min.css">
	<!-- Hamburger Menu -->
	<link rel="stylesheet" href="assets/css/hamburgers/hamburgers.css">

	<!-- CSS - REQUIRED - END -->

	<!-- CSS - OPTIONAL - START -->
	<!-- Font Awesome -->
	<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.min.css">
	<!-- JVMaps -->
	<link rel="stylesheet" href="assets/plugins/jvmaps/jqvmap.min.css">
	<!-- CSS - OPTIONAL - END -->

	<!-- QuillPro Styles -->
	<link rel="stylesheet" href="assets/css/quillpro/quillpro.css">
	<style type="text/css">
	.nosamepass {
  display: none;
}
	</style>
</head>

<body>

	<div class="container-fluid">
		<div class="row">
			

			<?php include('includes/leftnav.php') ?>
			
<div class="right-column">
    
    <div>
    
   
    
</div>
    
    				<?php include('includes/header.php') ?>
				<main class="main-content p-5" role="main">
				
				
				<div class="row">
						
			  </div>
					
					<div class="row">
					
					
					  
				



    <div class="main-panel">
        <div class="main-content">
          <div class="content-wrapper">
            <div class="container-fluid"><!-- User Profile Starts-->
<!--Basic User Details Starts-->

<!--Basic User Details Ends-->
<section id="user-area">
    <div class="row">
        <div class="col-xl-3 col-lg-12">
            <div class="card mb-4">
                <div class="card-header">
                    <div class="card-title-wrap bar-primary">
                        <div class="card-title">Personal Information</div>
                    </div>
                </div>
                <div class="card-body">
                    <div class="card-block">
                       
							<div class="text-center">
								<div class="card-body">
									
									<p class="mt-5 mb-4">Welcome!</p>
									<h4 class="" style="">

										<?php echo "$first_name"; ?> <?php echo "$last_name"; ?> </h4>



									 <div class="text-center">
                           
                        </div>
                           
									
									
								</div>
							</div>
					 
                       
                        </div>
                    </div>
                </div>
            
        </div>
        <div class="col-xl-9 col-lg-12">
            <!--About div starts-->
            <div id="about">
                <div class="row">
                    <div class="col-sm-12">
                        <div class="card">
                            <div class="card-header">
                                <div class="card-title-wrap bar-info">
                                    <div class="card-title">Update Personal Information</div>
                                </div>
                            </div>
                            <div class="card-body">
                                <div class="card-block">
                                    <form method="post" enctype="" id="form-profile">
                                      <div class="form-row">
                                      	<div class="col-6">
                                          <label>First Name</label>
                                          <input type="text" id="firstname" name="firstname" class="form-control" placeholder="First Name" value="<?php echo $first_name ?>">
                                        </div>
                                        <div class="col-6">
                                          <label>Last Name</label>
                                          <input type="text" id="lname" name="lastname" class="form-control" placeholder="Last Name" value="<?php echo $last_name ?>">
                                        </div>

                                         <div class="col-6">
                                          <label>Email</label>
                                          <input type="text" id="email" name="email" class="form-control" placeholder="Email" value="<?php echo $email ?>">
                                        </div>
                                      	 
                                        
                                        <div class="col-6">
                                          <label>Phone Number</label>
                                          <input type="number" id="phone" name="phone" class="form-control" placeholder="Phone Number" value="<?php echo $phone ?>">
                                        </div>
                                         
                                       

                                       
                                        <div class="col-12">
                                          <br>
                                          <input type="submit" id="submit" value="Submit" class="btn btn-sm pull-right" style="background: #0ca59d">
                                        </div>
                                      </div>
                                    </form>
                                </div>


			<?php
					if (isset ($_POST['firstname']) && isset ($_POST['lastname']) && isset ($_POST['phone']) && isset ($_POST['email']) )
					{
						$errors1 = array();
						  
							
							$firstname = mysql_real_escape_string($_POST['firstname']);
							$lastname = mysql_real_escape_string(($_POST['lastname']));

					


							
							$phone = mysql_real_escape_string($_POST['phone']);

							$email = mysql_real_escape_string($_POST['email']);

							
							

						if(!empty($firstname) && !empty($lastname) && !empty($phone) )
							{
								
								
								if(!ctype_alpha(str_replace(' ', '', $firstname))) {
									$errors1[] = 'First Name should contain only Alphabets';
									
									}else
									if(strlen($firstname) > 25 ) {
										$errors1[] = 'First Name is too long';
									}

								}

									else
								{
									$errors1[] = 'Please fill the form before submitting it!!!';
								}
							if(!empty($errors1))
							{
								foreach($errors1 as $error1) {
									
								echo '<div class="alert alert-danger col-md-12" role="alert">
                                <button type="button" class="close" data-dismiss="alert">
                                    <span aria-hidden="true">×</span>
                                    <span class="sr-only">Close</span>
                                </button>
                                <strong>Oh snap!</strong> ',$error1 ,'
                            </div>';
								
								}
							
							}

							else 		
								{
									

									
									$updatequery= "UPDATE `users` SET `firstname`='$firstname', `lastname`='$lastname', `phone`='$phone', `email`='$email' WHERE `user_id`='$user_id'";

                  
									mysql_query($updatequery) or die(mysql_error());
									echo '<div class="alert bg-success" role="alert">
					<svg class="glyph stroked cancel"><use xlink:href="#stroked-cancel"></use></svg> Your profile has been updated successfully<a href="#" class="pull-right"><span class="glyphicon glyphicon-remove"></span></a>
				</div>';


									header('Location:index.php');
								}		
					}

			
					
					


				?>

                            </div>
                        </div>
                    </div>
                    
                   
               
                </div>
            </div>
            <!--About div ends-->

            <!--User Timeline div starts-->
          
            <!--User Timeline div ends-->
        </div>
    </div>
</section>
<!--User Profile Starts-->
            </div>
          </div>
        </div>
    </div>













					  
					
						 
						
						
                          
                         
					</div>
					
		  </div>
					
				</main>
	  </div>
</div>
	</div>

	<!-- SCRIPTS - REQUIRED START -->
	<!-- Placed at the end of the document so the pages load faster -->
	<!-- Bootstrap core JavaScript -->
	<!-- JQuery -->
	<script type="text/javascript" src="assets/js/jquery/jquery-3.1.1.min.js"></script>
	<!-- Popper.js - Bootstrap tooltips -->
	<script type="text/javascript" src="assets/js/bootstrap/popper.min.js"></script>
	<!-- Bootstrap core JavaScript -->
	<script type="text/javascript" src="assets/js/bootstrap/bootstrap.min.js"></script>
	<!-- MDB core JavaScript -->
	<script type="text/javascript" src="assets/js/bootstrap/mdb.min.js"></script>
	<!-- Velocity -->
	<script type="text/javascript" src="assets/plugins/velocity/velocity.min.js"></script>
	<script type="text/javascript" src="assets/plugins/velocity/velocity.ui.min.js"></script>
	<!-- Custom Scrollbar -->
	<script type="text/javascript" src="assets/plugins/custom-scrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
	<!-- jQuery Visible -->
	<script type="text/javascript" src="assets/plugins/jquery_visible/jquery.visible.min.js"></script>
	<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
	<script type="text/javascript" src="assets/js/misc/ie10-viewport-bug-workaround.js"></script>

	<!-- SCRIPTS - REQUIRED END -->

	<!-- ChartJS -->
	<script type="text/javascript" src="assets/plugins/chartjs/chart.bundle.min.js"></script>
	<!-- JVMaps -->
	<script type="text/javascript" src="assets/plugins/jvmaps/jquery.vmap.min.js"></script>
	<script type="text/javascript" src="assets/plugins/jvmaps/maps/jquery.vmap.usa.js"></script>

	<!-- SCRIPTS - OPTIONAL START -->
	<!-- Image Placeholder -->
	<script type="text/javascript" src="assets/js/misc/holder.min.js"></script>
	<!-- SCRIPTS - OPTIONAL END -->

	<!-- QuillPro Scripts -->
	<script type="text/javascript" src="assets/js/scripts.js"></script>
		<script type="text/javascript" src="assets/plugins/form-validator/jquery.form-validator.min.js"></script>
			<script type="text/javascript" src="assets/demo/js/forms-validation.js"></script>
			
			<script type="text/javascript">
			
			$("#amount").focusout(function(){
    
    
    if(parseFloat($("#prebalance").val()) < parseFloat($("#amount").val()))
    {
        $(".error").css("display","block").css("color","red");
        $("#submit").prop('disabled',true);
    }
    else {
        $(".error").css("display","none");
        $("#submit").prop('disabled',false);        
    }
    
});
			
			</script>
			
			
			<script type="text/javascript">
$(document).ready(function(){
    $(".input").keyup(function(){
          var val1 = +$(".value1").val();
          var val2 = +$(".value2").val();
          $("#balance").val(val1-val2);
   });
});
</script>


<script type="text/javascript">
$('input[name="amount"]').keyup(function(e)
                                {
  if (/\D/g.test(this.value))
  {
    // Filter non-digits from input value.
    this.value = this.value.replace(/\D/g, '');
  }
});


$('input[name="acctnumber"]').keyup(function(e)
                                {
  if (/\D/g.test(this.value))
  {
    // Filter non-digits from input value.
    this.value = this.value.replace(/\D/g, '');
  }
});
</script>


<script type="text/javascript">

$("#pass2").keyup(function() {
  if ($("#pass1").val() != $("#pass2").val()) {
    $(".nosamepass").fadeIn('slow');
    $("#choosepass > input").css("border", "1px solid #ff0033");
	$("#submit").prop('disabled',true);
  } else {
    $(".nosamepass").fadeOut('slow');
    $("#choosepass > input").css("border", "1px solid #232323");
	$("#submit").prop('disabled',false);
  }
});

</script>




</body>

</html>

