diff --git a/api/save_lpa.php b/api/save_lpa.php index f5f01f5..45567af 100644 --- a/api/save_lpa.php +++ b/api/save_lpa.php @@ -480,6 +480,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $postcode = $_POST['correspondence_postcode'] ?? ''; $contact_preference = isset($_POST['correspondence_contact_preference']) ? (is_array($_POST['correspondence_contact_preference']) ? implode(',', $_POST['correspondence_contact_preference']) : $_POST['correspondence_contact_preference']) : 'Post'; $phone = $_POST['correspondence_phone'] ?? ''; + if (!empty($phone) && (strlen($phone) > 14 || !preg_match("/^[0-9+ ]+$/", $phone))) { + echo json_encode(["success" => false, "error" => "Phone number must be maximum 14 characters and only contain digits, + or spaces."]); + exit; + } $email = $_POST['correspondence_email'] ?? ''; if ($correspondence_who !== 'Donor') { @@ -529,9 +533,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $payment_method = $_POST['payment_method'] ?? 'Card'; $payment_phone = $_POST['payment_phone'] ?? ''; + if (!empty($payment_phone) && (strlen($payment_phone) > 14 || !preg_match("/^[0-9+ ]+$/", $payment_phone))) { + echo json_encode(["success" => false, "error" => "Phone number must be maximum 14 characters and only contain digits, + or spaces."]); + exit; + } $reduced_fee_eligibility = $_POST['reduced_fee_eligibility'] ?? 'No'; $is_repeat_application = isset($_POST['is_repeat_application']) ? 1 : 0; $repeat_case_number = $_POST['repeat_case_number'] ?? ''; + if ($is_repeat_application && strlen($repeat_case_number) > 12) { + echo json_encode(['success' => false, 'error' => 'The Original Case Number must not exceed 12 characters.']); + exit; + } if ($payment_method === 'Card' && empty($payment_phone)) { echo json_encode(['success' => false, 'error' => 'Please provide a phone number for card payment.']); diff --git a/apply.php b/apply.php index 5755f0d..6faeae3 100644 --- a/apply.php +++ b/apply.php @@ -1061,7 +1061,7 @@ foreach ($notified_persons as $np) {