Hi all,
Can anyone tell me how to get the second foreach(), ie:
foreach ($_POST['company_id'] as $cool){
to upload once. At the moment it is uploading to the DB twice.
Here is the code:
if($email){
function mkpasswd($nochars=8)
{
mt_srand ((double) microtime() * 1000000);
$letters=" ABCDEFGHJKLMPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz2345
6789";
$len=strlen($letters);
for ($loop=0; $loop<$nochars; $loop++)
{
$randno=mt_rand(0,$len);
$password.=substr($letters, $randno, 1);
}
return($password);
}
foreach ($_POST['checkbox_email'] as $value){
$password = mkpasswd($nochars=8);
$sendto = "$value";
$subject = "Listing Renewal";
$message = "Dear.....\n\nClick the link below to update your listing.\n\nhttp://infoquorum.ripefruit.com.au/client_update.php\n\nUsername: $value\n\nPassword: $password";
$from = "From: Xer Publishing <webmaster@infoquorum.com>";
mail($sendto, $subject, $message, $from);
foreach ($_POST['company_id'] as $cool){
$insert_email = "insert into client_admin(client_admin_id,company_id,login_email,password)
values (NULL,'$cool','$value','$password')";
$result_email = mysql_query($insert_email);
if($result_email){
echo "Email Sent";
} else {
echo "Email could not be sent";
}
}
}
}
Cheers,
micmac