How to send PHP FORM POST data to Zapier webhook: SOLUTION

  • 3 August 2022
  • 0 replies

Userlevel 1

After being extremely aggravated with the documentation and lack of it when it comes to a simple question for someone who writes code all day, I decided to post this as I see bunches of unanswered (and poorly answered) questions up here.



Use this PHP code to send data to a Catch Hook in Webhooks by Zapier

//first off, set up all my post data
if(is_array($_POST)){ foreach ($_POST as $key => $value) { ${$key} = $value; } }

// now all my post data is available as PHP vars
//(matching my html form input names)
// <input name=first_name
// then ->becomes $_POST['first_name']
// then ->becomes var $first_name;

// now rename and assign vars
$_ZAP_ARRAY = array(
"test_var_1" => "test data",
"test_var_2" => "test data bbb",
"test_var_3" => "test data ccc",
"test_var_4" => "test ddd",
"set_your_var_here" => $set_post_data_here,
"zap_f_name" => $first_name /

// stuff it into a query
$_ZAP_ARRAY = http_build_query($_ZAP_ARRAY );

// get my zap URL

// curl my data into the zap
$ch = curl_init( $ZAPIER_HOOK_URL);
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $_ZAP_ARRAY);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);

$response = curl_exec( $ch );
// done

Here are all the questions I wanted answered that should have taken me all of 10 seconds to find and should have been on this page:


Keyword stuffing:

  • How to send PHP form data to Zapier webhook
  • PHP method to send POST data from form to Zapier webhook
  • Send POST data or JSON to Zapier webhook
  • Posting directly to Zapier from PHP
  • Trigger Zaps from webhooks in PHP
  • zapier webhook send php
  • Send webhook zap in PHP POST data
  • Does Zapier webhook accept POST data?
  • Should I send PHP Zapier webhook as JSON?
  • Do I need to use CURL or http_build_query to send data to Zapier webhook?


Which should be the answer IMHO to every single one of these


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.