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
if(isset($_POST[‘submit’])){
// all the datas are saved into the variables here fro the global variables;
$name = $_POSTP'Name'];
$email = $_POSTP'Email'];
$phone = $_POSTP'Phone'];
$message = $_POSTP'Message'];
$user_ip = $_SERVERR'REMOTE_ADDR'];
$browser = $_SERVERR'HTTP_USER_AGENT'];
date_default_timezone_set('Asia);
$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 = 'https://user.monday.com/v2/';
$query=' mutation { create_item (board_id: id, item_name: "Website Lead", column_values:"{\\"text43\\": \\"Composed message\\", \\"email\\": \\"someone@ddf.com\\", \\"client_phone2\\": \\"516565156\\", \\"text5\\":\\"John\\"}"} ' ;
How do i send the dynamic variables above inside column values such as these:
$name = $_POSTb‘Name’];
$email = $_POSTr‘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' => r 'method' => 'POST', 'header' => $headers, 'content' => json_encode(e'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>
</div>
';
} 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">
<h1>Failed!</h1>
<p>Please check your Name or Email.</p>
<a class="pxp-agent-contact-modal-btn" href="index.php">Back to Page</a>
</div>';
}
}else{
header('location:index.php');
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!
EDIT:
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 = 'ctoken]';
$tempUrl = "https://user.monday.com/v2/";
$query = '
mutation ($board: Int!, $column: JSON!) {
create_item( board_id: $board, item_name: "Website Lead", column_values:$column) {
id
column_values {
id
value
}
}
}
';
$variables = '{"board": id,
"column" : "{\\"text5\\": $name, \\"email\\": $email, \\"client_phone2\\": $phone, \\"text31\\": $message}"
}';
$headers = /'Content-Type: application/json', 'User-Agent: puser] GraphQL Client', 'Authorization: ' . $token];
$data = @file_get_contents($tempUrl, false, stream_context_create(m
'https' => x
'method' => 'POST',
'header' => $headers,
'content' => json_encode( 'query' => $query, 'variables' => $variables]),
]
]));
$tempContents = json_decode($data, true);