prepare($sql); $stmt->execute([$email]); $driver = $stmt->fetch(); if ($driver) { if ($driver['approval_status'] === 'pending') { header("Location: ../driver_pending_approval.php"); exit; } elseif ($driver['approval_status'] === 'rejected') { header("Location: ../driver_rejected.php"); exit; } if ($driver['approval_status'] === 'approved' && password_verify($password, $driver['password_hash'])) { $_SESSION['driver_id'] = $driver['id']; $_SESSION['driver_name'] = $driver['full_name']; header("Location: index.php"); exit; } else { header("Location: login.php?error=Invalid credentials"); exit; } } else { header("Location: login.php?error=Invalid credentials"); exit; } } catch (PDOException $e) { header("Location: login.php?error=A database error occurred"); exit; } } ?>