Psyduck - 可達鴨 之 鴨力山大 v0.1

Current Path : home/irplbiz/www/g-sheet/
Upload File :
Current File : /home/irplbiz/www/g-sheet/submit.php

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $url = 'https://script.google.com/macros/s/AKfycbxWpFh55zWvi5x_mI5gGLmjYGovm-uq9-zmmZ_KlHLYrqdnkhG11I03FFE5uYi9LcaOfg/exec'; // Replace with your Google Apps Script Web App URL

	date_default_timezone_set("Asia/Kolkata");
	$today = date("d-m-Y H:i:s");

    $postData = array(
	    'date' => $today,
        'name' => $_POST['name'],
        'email' => $_POST['email'],
        'message' => $_POST['message'],
    );

    $ch = curl_init($url);


    $postFields = http_build_query($postData);

    curl_setopt($ch, CURLOPT_POST, 1); // Send a POST request
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields); // Attach the POST fields
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return the response as a string

    $response = curl_exec($ch);

    if ($response === false) {
        $error = curl_error($ch);
        echo "cURL error: $error";
    } else {
        //echo "Server response: $response";
    }

    curl_close($ch);
}
?>