File "update_applicant.php"
Full path: /home/fsibplc/public_html/fsib/remittance/update_applicant.php
File
size: 1.42 B
MIME-type: text/x-php
Charset: utf-8
Download Open Edit Advanced Editor Back
<?php
header('Content-Type: application/json');
// Database configuration
$host = 'localhost'; // Your database host
$dbname = 'fsibplc_account_opening'; // Your database name
$username = 'root'; // Your database username
$password = ''; // Your database password
try {
// Create a new PDO instance
$pdo = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Get the JSON input
$input = json_decode(file_get_contents('php://input'), true);
$accountNumber = $input['accountNumber'];
$informed = $input['informed'];
$id = $input['index']; // This index can be used to identify the specific applicant
if($accountNumber != "NULL"){
$status = "Approved";
}
else{
$status = "NULL";
}
// Update the applicant's account_number and informed status
$update_stmt = $pdo->prepare("UPDATE account_info SET ac_number = :accountNumber, account_info.status = :statusUpdate, inform = :informed WHERE id = :id");
$update_stmt->execute([
':accountNumber' => $accountNumber,
':informed' => $informed,
':statusUpdate' => $status,
':id' => $id // Assuming ID is sequential starting from 1
]);
echo json_encode(['success' => true]);
} catch (PDOException $e) {
echo json_encode(['success' => false, 'error' => $e->getMessage()]);
}
?>