Click here to Skip to main content
13,045,790 members (45,515 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi guys!

My friend is trying to get more people to sign up for his newsletter on ConstantContact, but he also wants to get visitor feedback mailed directly to him.

I have his HTML form posting to a PHP file on the server. That PHP is currently 1/2 working, as it successfully sends an email to me with the visitor comments in it. Now, I just need it to also send the 4 variables along to ConstantContact.

If it was an HTML form directly posting to ConstantContact, the action would be: "action="" but it is PHP, so I assume the syntax is different.

And here is my current PHP file that is successfully 1/2 working:
$emailSubject = 'Customer Has a Question!';
$webMaster = '';
$ea = $_POST['ea'];
$comments = $_POST ['comments'];
$llr = $_POST ['llr'];
$m = $_POST ['m'];
$p = $_POST ['p'];
$body = <<<EOD
Email: $ea <br>
Comments: $comments <br>
And below are the four variables sent to Constant Contact:<br>
Email: $ea <br>
LLR: $llr <br>
M: $m <br>
P: $p <br>
These comments were sent from the test.html page of the JW Secure site. <br>
The visitor has checked the box that would send their information to Constant Contact.<br>
$headers = "From: $ea\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);
$theResults = <<<EOD
<META http-equiv="refresh" content="0;URL=">
echo "$theResults";

And if it helps, here is the form from the HTML. The hidden variables are just things for ConstantContact, so we have values for each of those, we just need to pass them along to CC.

<form action="SendToConstantContact.php" name="myform" method="post" onsubmit="return submitForm(this)">
Your email*:<br/>
<input type="text" name="ea" size="39" value="" style="font-size:10pt;"><br/>
<img src="images/transparent.gif" width="1" height="9" alt="" border="0" /><br/>
Your message (optional):<br/>
<textarea name="comments" cols="30" rows="3" style="font-size:10pt;">
<img src="images/transparent.gif" width="1" height="9" alt="" border="0" /><br/>
<input type="hidden" name="llr" value="z4u4kndab">
<input type="hidden" name="m" value="1103180583929">
<input type="hidden" name="p" value="oi">
<input type="submit" value="Submit" />

So, my question is, how do I do 2 things in my PHP file? 1. send the email to Dan (this part is working) and 2. also send the variables to ConstantContact via this PHP page (I need help with this part)?

I've tried to find the answer on PHP sites but so far it has eluded me. Thank you for your time and expertise.
Posted 26-Jun-13 7:02am
Updated 28-Jun-13 14:34pm
Killzone DeathMan 28-Jun-13 12:37pm
you have an error there ...
"$questionField" - is unused
"$comments" - is not declared

maybe you mean:
$comments = $_POST ['comments'];
pygmydynamo 28-Jun-13 20:06pm
I think that is what I mean. Thank you! I've updated the code. -Barry
Killzone DeathMan 28-Jun-13 12:48pm
Maybe in your friends page must be the fields, and when all are validated, just do something like:

type: "POST",
url: "youphpfile.php",
data: {"ea":"", "comments":"So easy!", "llr":"WTFisTHIS", "m":"mmm","p":"ppp"},
success: function(){
alert('Email send successfully!');
dataType: "json"

This will execute your 1/2 done PHP script to send the email...
want a tip? smoke marijuana and all will be OK! xD
pygmydynamo 28-Jun-13 20:26pm
Hi KZ! Thanks for the feedback!

I've tried adding this $.ajax in, and replacing the youphpfile.php and, but it causes a white page error when the visitor clicks submit... it just hangs on my php page.

To answer your questions, llr, m, and p are all hidden fields from the HTML form. They're numbers that ConstantContact cares about, apparently. For example,
<input type="hidden" name="m" value="1103180583929">

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 28 Jun 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100