I've got a form for adding users by an administrator that have filled in a paper based form. The online form allows up to 50 contacts to be added in one time, by checking if each name/email field is completed, and if so adding it to the database through a for loop.
I want to now integrate constant contact into this, but it will only add 1 contact at a time, when I need it to add all completed. The basics of my code are:
include_once('cc_class.php');
for ($i=1; $i <=50; $i++) {
$ccContactOBJ = new CC_Contact();
$name = "name" . $i;
$email = "email" . $i;
$name = $_POST;
$email = $_POST;
if ($email != "" && $name != "") {
$query = sprintf("SELECT * FROM users WHERE email = '%s'", mysql_real_escape_string($email));
$result= mysql_query($query);
if (mysql_num_rows($result) == 0) {
$query = sprintf("INSERT INTO users VALUES ('', '%s', '%s', '1', '1')", mysql_real_escape_string($email), mysql_real_escape_string($name));
mysql_query($query);
$name = "name" . $i;
$email = "email" . $i;
$postFields = array();
$postFields = $_POST;
$postFields = $_POST;
$postFields = "";
$postFields = "";
$postFields = "";
$postFields = "";
$postFields = "";
$postFields = "";
$postFields = "";
$postFields = "";
// The Code is looking for a State Code For Example TX instead of Texas
$postFields = "";
$postFields = "";
$postFields = "";
$postFields = "";
$postFields = "";
$postFields = $_POST;
$contactXML = $ccContactOBJ->createContactXML(null,$postFields);
if (!$ccContactOBJ->addSubscriber($contactXML)) {
$error = true;
} else {
$error = false;
$_POST = array();
}
if (isset($error)) {
if ($error === true) {
$class = "error";
$message = $ccContactOBJ->lastError;
} else {
$class = "success";
$message = "Contact ".$_POST." Added.";
}
echo '<div class="'.$class.'">';
echo $message;
echo '</div>';
}
}
Can anyone help with this please? I'm sure there must be an easy way around it to add multiple.
Thanks, John
... View more