I am creating a small e-card system and I have a script that runs to remove people who want to opt-out of it. When someone adds up to 480 email addresses they want to send out, it works. If they add more than 480 it writes to the DB as blank.
Here is the code below:
index.php
Code: Select all
function post_variables($action,$variables){
$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_URL, $action); //form action
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$variables);//form variables
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
$to_emails=post_variables("http://localhost/scripts/ecards/remove_opt_outs2.php","subject=Unclean Emails"."&email_list=".$to_emails."&sender_name=".$from_name."&sender_email=".$from_email."&email_subject=".$custom_greeting."&email_message=".$message."&image_name=".$images_web_location . $new_images[$id]."&image_url=".$target_url);Code: Select all
//FUNCTION: GET TABLE DATA
function get_table_data($database_connection,$sql_query){
//TABLE DATA
//get all of the data from the table and record it to an array with the keys recording the primary key and the field attributes - field name|primary key value|field type|field length eg. title|13|text|128
$all_data_array=array();
$query_result=mysql_query($sql_query,$database_connection);
while($query_row=mysql_fetch_row($query_result)){
for($d=0;$d<sizeof($query_row);$d++){
//define the array
if(!isset($all_data_array[mysql_field_name($query_result,$d)])){
$all_data_array[mysql_field_name($query_result,$d)]=array();
}
//add the item's attribute to the attributes array
$all_data_array[mysql_field_name($query_result,$d)][sizeof($all_data_array[mysql_field_name($query_result,$d)])]=$query_row[$d];
}
}
return $all_data_array;
}
function post_variables($action,$variables){
$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_URL, $action); //form action
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$variables);//form variables
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
if(isset($_POST["email_list"])){
$email_list=explode(",",$_POST["email_list"]);
//Loop through every email address
for($a=0;$a<sizeof($email_list);$a++){
get_table_data($database_connection,"SELECT email_address FROM `opt_outs` WHERE email_address='".$email_list[$a]."'");
//If this email address has been opted out, add it to the unclean list
if(mysql_affected_rows()>0){
$unclean_email_list[]=$email_list[$a];
}
//Otherwise add it to the clean list
else{
$clean_email_list[]=$email_list[$a];
}
}
//Record the ecard details
if(isset($clean_email_list)){
$included_recipients=sizeof($clean_email_list);
}else{
$included_recipients=0;
}
//Number of recipients who had previously opted out
if(isset($unclean_email_list)){
$excluded_recipients=sizeof($unclean_email_list);
}else{
$excluded_recipients=0;
}
print implode( ", ", $clean_email_list );
//Email the ecard details
post_variables("http://localhost/scripts/ecards/email_ecard_details.php",$ecard_info."&email_message=".$_POST["email_message"]."&recipient_email_addresses=".implode( ", ", $clean_email_list ));
}Can someone help point me in the right direction?
Thanks