<?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


$prescription_date = $_POST['prescription_date'];
$height = $_POST['height'];
$age = $_POST['age'];
$weight = $_POST['weight'];
$tablename= $_REQUEST['tablename'];
$appointment_id = $_REQUEST['appointment_id'];
$registration_id = $_REQUEST['registration_id'];
$program_id = $_REQUEST['program_id'];
$name = $_POST['name'];

$queryleadqf="update $tablename set height='$height',weight='$weight',age='$age',prescription_date='$prescription_date',prescription_status='START' where ibp_id = '".$_REQUEST['program_id']."'";
$resultleadqf=mysqli_query($conn,$queryleadqf);

//echo "<br>";


$qrycallan = "insert into  patient_activity(tablename,program_id,height,weight,age,prescription_date,prescription_id,patient_name,appointment_id,registration_id) values ('$tablename','$program_id','$height','$weight','$age','$prescription_date','$prescription_id','$name','$appointment_id','$registration_id')";
$rcallan=mysqli_query($conn,$qrycallan);



//exit();

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