Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: PHP Forms
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="http://visitor.r20.constantcontact.com/d.jsp" but it is PHP, so I assume the syntax is different.
 
And here is my current PHP file that is successfully 1/2 working:
<?php
$emailSubject = 'Customer Has a Question!';
$webMaster = 'barry@page3design.com';
 
$ea = $_POST['ea'];
$comments = $_POST ['comments'];
$llr = $_POST ['llr'];
$m = $_POST ['m'];
$p = $_POST ['p'];
 
$body = <<<EOD
<br><hr><br>
Email: $ea <br>
Comments: $comments <br>
&nbsp;<br>
And below are the four variables sent to Constant Contact:<br>
Email: $ea <br>
LLR: $llr <br>
M: $m <br>
P: $p <br>
 
&nbsp;<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>
EOD;
$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=http://www.jwsecure.com/contact/thank-you/">
EOD;
 
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;">
</textarea><br/>
<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" />
</form>
 
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.
-Barry
Posted 26-Jun-13 8:02am
Edited 28-Jun-13 15:34pm
v3
Comments
Killzone DeathMan at 28-Jun-13 12:37pm
   
you have an error there ...
"$questionField" - is unused
"$comments" - is not declared
 
maybe you mean:
$comments = $_POST ['comments'];
pygmydynamo at 28-Jun-13 20:06pm
   
I think that is what I mean. Thank you! I've updated the code. -Barry
Killzone DeathMan at 28-Jun-13 12:48pm
   
Maybe in your friends page must be the fields, and when all are validated, just do something like:
 
$.ajax({
type: "POST",
url: "youphpfile.php",
data: {"ea":"cliente_mail@example.com", "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
Regards,
KZ
pygmydynamo at 28-Jun-13 20:26pm
   
Hi KZ! Thanks for the feedback!
 
I've tried adding this $.ajax in, and replacing the youphpfile.php and client2_mail@example.com, 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
0 OriginalGriff 428
1 Maciej Los 249
2 BillWoodruff 199
3 /\jmot 180
4 Suraj Sahoo | Coding Passion 150
0 OriginalGriff 8,484
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,159
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 28 Jun 2013
Copyright © CodeProject, 1999-2014
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