function login_admin($username, $password) { global $pdo; try { $stmt = $pdo->prepare("SELECT * FROM admin WHERE username = ? LIMIT 1"); $stmt->execute([$username]); $admin = $stmt->fetch(); if ($admin) { if (password_verify($password, $admin['password'])) { $_SESSION['admin_id'] = $admin['id']; $_SESSION['admin_username'] = $admin['username']; $_SESSION['admin_email'] = $admin['email']; // Update last login $update = $pdo->prepare("UPDATE admin SET last_login = NOW(), last_ip = ? WHERE id = ?"); $update->execute([$_SERVER['REMOTE_ADDR'], $admin['id']]); return ['success' => true]; } return ['success' => false, 'message' => 'Invalid password']; } return ['success' => false, 'message' => 'Admin account not found']; } catch (PDOException $e) { error_log("Admin login error: " . $e->getMessage()); return ['success' => false, 'message' => 'Database error']; } } KAAROBAR - Complete Business Solution

Complete Business Management Solution

Streamline your business operations with our all-in-one platform

View Pricing

INVOICE GENERATION

INVOICE SHARING

STOCK INVENTORY

COMPANY ENTRY

GST BILLING

SERVICES

SALES

CLOUD-BASED TOOLS

Choose Your Plan

1 Month

Rs 150
  • 30 Days Access
  • Mobile + Desktop
  • All Features Included
Get Started

6 Months

Rs 500
  • 180 Days Access
  • Mobile + Desktop
  • All Features Included
  • Save Rs 400
Get Started

1 Year

Rs 999
  • 365 Days Access
  • Mobile + Desktop
  • All Features Included
  • Save Rs 801
Get Started

Try our platform for 10 Days Free Trial with no credit card required!

Start Free Trial