🚀 Hostinger Optimized
🖥️ Server: LiteSpeed
💻 System: Linux in-mum-web1643.main-hosting.eu 5.14.0-611.42.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Mar 24 05:30:20 EDT 2026 x86_64
👤 User: u621169360 (621169360)
🐘 PHP: 8.2.30
🚫 Disabled: system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail

💻 Terminal

📁 /home/u621169360/domains/agriexpertt.com/public_html/wp-admin
$

📄 partner_dashboard.php

📁 Path: /home/u621169360/domains/agriexpertt.com/public_html/mobile/Flutter/partner_dashboard.php
📊 Size: 4.67 KB
🔒 Perm: 0644
📝 MIME: text/x-php
<?php
// Enable CORS headers
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
header("Access-Control-Allow-Headers: Content-Type");
header('Content-Type: application/json');

require_once 'db.php';

$response = array();

// Handle OPTIONS request for CORS preflight
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
    http_response_code(200);
    exit();
}

// Determine request method
$method = $_SERVER['REQUEST_METHOD'];

if ($method === 'GET') {
    try {
        // Sanitize input for GET request (partner status check)
        
        $user_phone = filter_input(INPUT_GET, 'user_phone', FILTER_SANITIZE_STRING);

        // Validate required fields
        if ( empty($user_phone)) {
            throw new Exception("Missing user identification");
        }

        // Prepare SQL query to check partner status
        $sql = "SELECT status FROM partners WHERE  phone = :user_phone";
        $stmt = $pdo->prepare($sql);
        
        $stmt->bindParam(':user_phone', $user_phone);
        $stmt->execute();

        $partner = $stmt->fetch(PDO::FETCH_ASSOC);

        if ($partner) {
            $response = [
                'success' => true,
                'partner_status' => $partner['status']
            ];
        } else {
            $response = [
                'success' => false,
                'message' => 'No partner record found'
            ];
        }
    } catch(PDOException $e) {
        // Database-specific error
        $response = [
            'success' => false,
            'message' => 'Database error: ' . $e->getMessage()
        ];
    } catch(Exception $e) {
        // General validation or other errors
        $response = [
            'success' => false,
            'message' => $e->getMessage()
        ];
    }
} else if ($method === 'POST') {
    // Parse input data based on content type
    $input = $_POST;
    if (empty($input)) {
        $input = json_decode(file_get_contents('php://input'), true);
    }

    try {
        // Sanitize and validate input
       
        $user_phone = filter_var($input['user_phone'], FILTER_SANITIZE_STRING);
        $name = filter_var($input['name'], FILTER_SANITIZE_STRING);
        $email = filter_var($input['email'], FILTER_VALIDATE_EMAIL);
        $phone = filter_var($input['phone'], FILTER_SANITIZE_STRING);
        $address = filter_var($input['address'], FILTER_SANITIZE_STRING);

        // Validate required fields
        if (empty($user_id) || empty($user_phone) || empty($name) || 
            empty($email) || empty($phone) || empty($address)) {
            throw new Exception("Missing required fields");
        }

        // Validate phone number (10 digits)
        if (!preg_match('/^[0-9]{10}$/', $phone)) {
            throw new Exception("Invalid phone number");
        }

        // Check for existing partner registration
        $check_sql = "SELECT id FROM partners WHERE   phone = :phone OR email = :email";
        $check_stmt = $pdo->prepare($check_sql);
       
        $check_stmt->bindParam(':phone', $phone);
        $check_stmt->bindParam(':email', $email);
        $check_stmt->execute();

        if ($check_stmt->rowCount() > 0) {
            throw new Exception("Partner registration already exists");
        }

        // Prepare SQL insert statement
        $sql = "INSERT INTO partners (
            user_id, phone, name, email, phone, address, status
        ) VALUES (
            :user_id, :user_phone, :name, :email, :phone, :address, 'pending'
        )";
        
        $stmt = $pdo->prepare($sql);
        
        // Bind parameters
         
        $stmt->bindParam(':user_phone', $user_phone);
        $stmt->bindParam(':name', $name);
        $stmt->bindParam(':email', $email);
        $stmt->bindParam(':phone', $phone);
        $stmt->bindParam(':address', $address);
        
        // Execute the statement
        $stmt->execute();
        
        // Prepare success response
        $response = [
            'success' => true,
            'message' => 'Partner registration submitted successfully. Awaiting approval.',
            'partner_id' => $pdo->lastInsertId()
        ];
    } catch(PDOException $e) {
        // Database-specific error
        $response = [
            'success' => false,
            'message' => 'Database error: ' . $e->getMessage()
        ];
    } catch(Exception $e) {
        // General validation or other errors
        $response = [
            'success' => false,
            'message' => $e->getMessage()
        ];
    }
} else {
    // Invalid request method
    $response = [
        'success' => false,
        'message' => 'Invalid request method'
    ];
}

// Send JSON response
echo json_encode($response);
exit();
?>
← Back📥 Raw✏️ Edit🔒 Chmod
✨ File Manager Magic ✨