<?xml version="1.0"?><!-- generator="bbPress" -->

<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
>

<channel>
<title>MachForm Community Forums Topic: PHP help needed to integrate form with Campaign Monitor API</title>
<link>https://www.machform.com/forums/</link>
<description>MachForm Community Forums Topic: PHP help needed to integrate form with Campaign Monitor API</description>
<language>en</language>
<pubDate>Mon, 22 Jun 2026 10:32:12 +0000</pubDate>

<item>
<title>yuniar on "PHP help needed to integrate form with Campaign Monitor API"</title>
<link>https://www.machform.com/forums/topic/php-help-needed-to-integrate-form-with-campaign-monitor-api#post-11728</link>
<pubDate>Wed, 30 Mar 2011 16:51:12 +0000</pubDate>
<dc:creator>yuniar</dc:creator>
<guid isPermaLink="false">11728@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Sorry if I wasn't clear.&#60;br /&#62;
The code should be placed into the first line of the page where you embed the form, not the first line of the form code.&#60;/p&#62;
&#60;p&#62;So, let say you put the form into myform.php file.&#60;br /&#62;
Put the session_start(); code at the beginning of myform.php file.&#60;/p&#62;
&#60;p&#62;Regarding the form data array, I just noticed that you have copied the data into session variable, so you can ignore my last reply. You can use your original code:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;&#38;lt;?php print_r($_SESSION[&#38;#39;form_data&#38;#39;]); ?&#38;gt;&#60;/code&#62;&#60;/pre&#62;</description>
</item>
<item>
<title>blogjunkie on "PHP help needed to integrate form with Campaign Monitor API"</title>
<link>https://www.machform.com/forums/topic/php-help-needed-to-integrate-form-with-campaign-monitor-api#post-11727</link>
<pubDate>Wed, 30 Mar 2011 00:13:16 +0000</pubDate>
<dc:creator>blogjunkie</dc:creator>
<guid isPermaLink="false">11727@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Hi Yuniar, now my form embed code is like this:&#60;/p&#62;
&#60;pre&#62;
&#38;lt;?php
	session_start();
	require(&#34;/path/to/machform/machform.php&#34;);
	$mf_param['form_id'] = 1;
	$mf_param['base_path'] = 'http://example.com/machform/';
	display_machform($mf_param);
?&#38;gt;
&#38;lt;?php print_r($table_data); ?&#38;gt;
&#60;/pre&#62;
&#60;p&#62;This is what I'm getting now:&#60;/p&#62;
&#60;pre&#62;
Warning: session_start() [function.session-start]: Cannot send
session cookie - headers already sent by (output started at
/path/to/form.php:10) in /path/to/form.php on line 11
&#60;/pre&#62;
&#60;p&#62;Btw I enabled the review page feature.
&#60;/p&#62;</description>
</item>
<item>
<title>yuniar on "PHP help needed to integrate form with Campaign Monitor API"</title>
<link>https://www.machform.com/forums/topic/php-help-needed-to-integrate-form-with-campaign-monitor-api#post-11726</link>
<pubDate>Tue, 29 Mar 2011 20:10:05 +0000</pubDate>
<dc:creator>yuniar</dc:creator>
<guid isPermaLink="false">11726@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;1) On the page where you embed the form, line 1, insert the following code:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;session_start();&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;that should start the session on that page and prevent the session expired error.&#60;/p&#62;
&#60;p&#62;2) The &#34;$table_data&#34; is the array. You can dump this array to see all the indexes.&#60;br /&#62;
You can use this simple code:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;print_r($table_data);&#60;/code&#62;&#60;/pre&#62;</description>
</item>
<item>
<title>blogjunkie on "PHP help needed to integrate form with Campaign Monitor API"</title>
<link>https://www.machform.com/forums/topic/php-help-needed-to-integrate-form-with-campaign-monitor-api#post-11720</link>
<pubDate>Tue, 29 Mar 2011 08:44:52 +0000</pubDate>
<dc:creator>blogjunkie</dc:creator>
<guid isPermaLink="false">11720@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;I'm trying to add names, email addresses and a country drop down field to Campaign Monitor via their &#60;a href=&#34;http://campaignmonitor.com/api&#34;&#62;API&#60;/a&#62;. I followed instructions from the forums and here is what I have done so far.&#60;/p&#62;
&#60;p&#62;First, inside post-functions.php, under &#60;code&#62;$process_result[&#38;#39;status&#38;#39;] = true;&#60;/code&#62; on line 1215 I added &#60;code&#62;include &#38;#39;custom.php&#38;#39;;&#60;/code&#62;. This is the contents of custom.php:&#60;/p&#62;
&#60;pre&#62;
define('MACHFORM_DIR', '/path/to/machform');

// include CM subscriber api class
require_once (MACHFORM_DIR . '/lib/createsend-php/csrest_subscribers.php');

if ($form_id == 1) {
	$wrap = new CS_REST_Subscribers('MYAPIKEY', 'MYLISTID');
	$result = $wrap-&#38;gt;add(array(
	    'EmailAddress' =&#38;gt; $table_data['element_2'],
	    'Name' =&#38;gt; $table_data['element_3'],
	    'CustomFields' =&#38;gt; array(
	        array(
	            'Key' =&#38;gt; 'Country',
	            'Value' =&#38;gt; '$table_data[\'element_15\']', // NEED TO FIGURE OUT THE INDEX FOR THIS
	            'Key' =&#38;gt; 'DateofBirth',
	            'Value' =&#38;gt; '$table_data[\'element_4\']'
	        )
	    ),
	    'Resubscribe' =&#38;gt; true
	));
}
&#60;/pre&#62;
&#60;p&#62;A little lower in my post-functions.php under &#60;code&#62;$process_result[&#38;#39;status&#38;#39;] = true;&#60;/code&#62;, I added this code:&#60;/p&#62;
&#60;pre&#62;
$_SESSION['form_data'] = $table_data;
&#60;/pre&#62;
&#60;p&#62;Next on the PHP page that I display the form, I have this:&#60;/p&#62;
&#60;pre&#62;
&#38;lt;?php
	session_start();
	require(&#34;/path/to/machform/machform.php&#34;);
	$mf_param['form_id'] = 1;
	$mf_param['base_path'] = 'http://www.example.com/machform/';
	display_machform($mf_param);
?&#38;gt;

&#38;lt;?php print_r($_SESSION['form_data']); ?&#38;gt;
&#60;/pre&#62;
&#60;p&#62;The problem that I'm facing:&#60;/p&#62;
&#60;p&#62;1. When I submit the form, I get a message saying &#34;Your session has been expired. Please start again.&#34; and the data is not saved to Machform&#60;/p&#62;
&#60;p&#62;2. I want to see the form_data array so I can figure out the values for Country and DateofBirth to send to Campaign Monitor.&#60;/p&#62;
&#60;p&#62;I think it must be something simple but I just can't find it. Please help, thanks
&#60;/p&#62;</description>
</item>

</channel>
</rss>
