POST request using PHP

Hi, really need your help, im trying to post some data from a website into monday

this is the below code. I am new to php and monday, can you please help me with this? Its urgent


// all the datas are saved into the variables here fro the global variables;

$name = $_POST['Name'];
$email = $_POST['Email'];
$phone = $_POST['Phone'];
$message = $_POST['Message'];
$user_ip = $_SERVER['REMOTE_ADDR'];
$browser = $_SERVER['HTTP_USER_AGENT'];
$date = date('d/m/Y h:i:s a', time());

if($message == “”){

$message = “NIL”;


$recipient = “email_id” ;
$subject = "Message from ".$name ;
$message = "
**Name:**  ".$name. "

**Email:**  " .$email. "

**Phone:**  " .$phone. "

**Message:**  " .$message. "

**Ip Address:**  " .$user_ip. "

**Browser:**  " .$browser. "

**Date:**  " .$date. “

$body = "<html>\n";
$body .= "<body style=\"font-family:Verdana, Verdana, Geneva, sans-serif; font-size:12px; color:#666666;\">\n";
$body = $message;
$body .= "</body>\n";
$body .= "</html>\n";

$headers  = ".$email.";
$headers .= "Reply-To: ".$mail_id."\r\n";
$headers .= "X-Mailer: PHP\n";
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

if( mail($recipient, $subject, $message, $headers) ) {
// Insert you code for processing the form here, e.g emailing the submission, entering it into a database.

$token = '[ token]';

$url = '';

$query=' mutation { create_item (board_id: id, item_name: "Website Lead", column_values:"{\"text43\": \"Composed message\", \"email\": \"\", \"client_phone2\": \"516565156\", \"text5\":\"John\"}"} ' ; 

How do i send the dynamic variables above inside column values such as these:
name = _POST[‘Name’];
email = _POST[‘Email’];
phone = _POST[‘Phone’];
message = _POST[‘Message’];

This is my header:

$headers = ['Content-Type: application/json', 'Authorization:' . $token]; $data = @file_get_contents($url, false, stream_context_create([ 'https' => [ 'method' => 'POST', 'header' => $headers, 'content' => json_encode(['query' => $query]), ] ]));

$tempContents = json_decode($data, true);	

	echo '
		<div class="row thank-card">
   <h1>Thank You!</h1>
   <p>Your enquiry request has been successfully submitted</p>
  <a class="pxp-agent-contact-modal-btn" href="index.php">Back to Page</a>

} else {
// Insert your code for showing an error message here

	//echo 'Sorry, you have provided an invalid security code';
	echo '<div class="row error-card">
   <p>Please check your Name or Email.</p>
  <a class="pxp-agent-contact-modal-btn" href="index.php">Back to Page</a>




finally do i need to execute this command or will the post request get activated automatically?

Preferably if i could get the right code to execute this would be perfect. Because ive tried everything and i cant seem to figure it out

Thanks a lot for your help!


I ended up changing the code a bit after looking around. Dont know if i have gone further away from solving my problem or gotten closer

   $token = '[token]';
    $tempUrl = "";
    $query = '
        mutation ($board: Int!, $column: JSON!) { 
        create_item( board_id: $board, item_name: "Website Lead", column_values:$column) { 
        column_values { 
    $variables = '{"board": id, 
     "column" : "{\"text5\": $name, \"email\": $email, \"client_phone2\": $phone, \"text31\": $message}"

    $headers = ['Content-Type: application/json', 'User-Agent: [user] GraphQL Client', 'Authorization: ' . $token];
    $data = @file_get_contents($tempUrl, false, stream_context_create([
    'https' => [
    'method' => 'POST',
    'header' => $headers,
    'content' => json_encode(['query' => $query, 'variables' => $variables]),
    $tempContents = json_decode($data, true);

Hey Madushan,

Dipro here! Are you finding that the item is created successfully but the column values are not added?

Not super familiar with PHP but I can definitely help with the side :slight_smile: When you send a value to a column, you need to ensure it is formatted appropriately based on the type of column. Your code does not do this. An email column has different fields than a text column, and therefore the data you send needs to be structured differently.

Here’s an example of what the email column’s formatting should look like (column1 is the column ID in this example):
{"column1" : {"email" : "", "text" : "John's Email"}}

When you send this data to the column, the results in the GUI will be as such:

You can get a list of all of the column structures in our documentation.

As for the code itself, I noticed that the variables section you should be passing the board ID as $id and not simply id.



tried this. but didnt work here is how it looks now:

    $query = `
        mutation ($board: Int!, $column: JSON!) { 
        create_item( board_id: $board, item_name: "Website Lead", column_values:$column) { 
        column_values { 
    $variables = `{"board": $id,{"email" : {"email" : "", "text" : "John's Email"}}