home/abhiramc/public_html/acts.service/fetch_adhar.php000064400000002565150211473270017110 0ustar00getConnection(); // Check if the empid is sent via POST if ($_SERVER['REQUEST_METHOD'] == 'POST') { $empid = $_POST['empid']; // Dynamically pass the empid from the AJAX request // Prepare the query to fetch the Aadhar number for the given empid $query = "SELECT empadharnumber FROM acts_emp WHERE empid = :empid"; $stmt = $db->prepare($query); $stmt->bindParam(':empid', $empid, PDO::PARAM_INT); $stmt->execute(); // Check if a result is returned if ($stmt->rowCount() > 0) { // Fetch the result $row = $stmt->fetch(PDO::FETCH_ASSOC); // Return the Aadhar number as a JSON response echo json_encode([ 'success' => true, 'empadharnumber' => $row['empadharnumber'] // Return the Aadhar number ]); } else { // If no result is found, return a failure response echo json_encode(['success' => false]); } exit(); // Stop further processing after sending the response } else { // If the request is not a POST or empid is not set, return an error echo json_encode(['success' => false, 'message' => 'Invalid request']); exit(); } ?>