false,'message'=>'Invalid request']); exit; } $email = cleanInput($_POST['email']); $password = $_POST['password']; $stmt = $conn->prepare("SELECT * FROM customers WHERE email = ? AND status = 1"); $stmt->bind_param("s", $email); $stmt->execute(); $customer = $stmt->get_result()->fetch_assoc(); if ($customer && password_verify($password, $customer['password'])) { $_SESSION['customer_id'] = $customer['id']; $_SESSION['customer_name'] = $customer['name']; $_SESSION['customer_email'] = $customer['email']; addActivityLog('login', "Customer {$customer['name']} logged in", 'customer', $customer['id']); echo json_encode(['success'=>true,'message'=>'Login successful!','redirect'=>SITE_URL . 'customer/dashboard.php']); } else { echo json_encode(['success'=>false,'message'=>'Invalid email or password']); }