<?php 
include 'connection.php';
session_start();
if (!isset($_SESSION['is_logged_in'])) {
    header("Location:login.php");
    die();
    }
	
date_default_timezone_set('Asia/Calcutta');
$today = date("d-m-Y");
$time = date("h:i A"); 
$currentyear = date("Y");

function randomPassword() {
    $alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    $pass = array(); //remember to declare $pass as an array
    $alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
    for ($i = 0; $i < 5; $i++) {
        $n = rand(0, $alphaLength);
        $pass[] = $alphabet[$n];
    }
    return implode($pass); //turn the array into a string
}
$unique_id = randomPassword();


?>
<?php 
$querylogin = "select * from  users where username = '". $_SESSION["LOGIN_NAME"]."' AND password = '".$_SESSION["EMPLOYEE_PASSWORD"]."'";
$resultlogin = mysqli_query($conn,$querylogin);
while($row=mysqli_fetch_array($resultlogin))
{
$user_id = $row['user_id'];
$first_name = $row['first_name'];
$login_type=$row['login_type'];
}

?>



  
<?php

$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$mobileno = $_POST['mobileno'];
$designation = $_POST['designation'];
$department = $_POST['department'];
$username = $_POST['username'];
$password = $_POST['password'];


$querycf="update users set first_name = '$first_name',last_name='$last_name',mobileno='$mobileno',designation='$designation',department='$department',username='$username',password='$password' where user_id = '".$_REQUEST['user_id']."'";
$resultcf=mysqli_query($conn,$querycf);






//exit();

?>
<script>
javascript:window.location.href="index.php";
</script>
