Files
Siro/backend/ride/egyptPhones/syrianAdd.php
Hamza-Ayed 72eeb24cd7 Fix #18: Exception leak remediation across 87 PHP files
- Replaced all client-facing $e->getMessage() with generic error messages
- Added error_log() with filename prefix to all catch blocks
- Covered jsonError(), echo, and json_encode() response patterns
- Also fixed 2 remaining display_errors=1 and add_invoice.php leak
- Script-assisted fix for 75 files, manual fix for 12 remaining edge cases
2026-06-17 07:48:31 +03:00

38 lines
1.5 KiB
PHP

<?php
require_once __DIR__ . '/../../connect.php'; // تأكد من أن هذا المسار صحيح
// --- استقبال البيانات من التطبيق ---
$driverId = filterRequest("driverId");
$name = filterRequest("name");
$phone = filterRequest("phone");
// --- التحقق من وجود البيانات الضرورية ---
if (empty($driverId) || empty($phone)) {
jsonError("Driver ID and Phone number are required.");
exit();
}
// --- إعداد استعلام SQL ---
// نستخدم "INSERT IGNORE" لتجنب إدخال سجلات مكررة بناءً على المفتاح الفريد (driverId, phone)
// إذا كان السجل موجوداً مسبقاً، سيتجاهله الاستعلام ببساطة
$sql = "INSERT IGNORE INTO `contactSyria`(`driverId`, `name`, `phone`) VALUES (:driverId, :name, :phone)";
$stmt = $con->prepare($sql);
$stmt->bindParam(':driverId', $driverId);
$stmt->bindParam(':name', $name);
$stmt->bindParam(':phone', $phone);
try {
$stmt->execute();
// rowCount() ستكون 1 عند إضافة سجل جديد، و 0 عند تجاهل سجل مكرر
if ($stmt->rowCount() > 0) {
jsonSuccess(null, "New contact saved successfully");
} else {
jsonSuccess(null, "Contact already exists for this driver.");
}
} catch (PDOException $e) {
// إرجاع رسالة خطأ في حال حدوث مشكلة في قاعدة البيانات
jsonError("An internal error occurred. Please try again later.");
}
?>