How can PHP developers ensure that the price request feature is secure and user-friendly for online shop customers?

To ensure that the price request feature is secure and user-friendly for online shop customers, PHP developers can implement server-side validation to sanitize and validate user input before processing the request. Additionally, they can use HTTPS to encrypt data transmission and implement measures such as input filtering and output escaping to prevent SQL injection and XSS attacks.

// Server-side validation to sanitize and validate user input
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $price = filter_input(INPUT_POST, 'price', FILTER_SANITIZE_NUMBER_FLOAT);
    
    if ($price) {
        // Process the price request
    } else {
        // Handle invalid input
    }
}

// Implement HTTPS for secure data transmission
if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] !== 'on') {
    header("Location: https://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
    exit();
}

// Input filtering and output escaping to prevent SQL injection and XSS attacks
$price = mysqli_real_escape_string($conn, $_POST['price']);
echo htmlspecialchars($price);