Hi all,
I've been playing with this bit of code but can't seem to stop it from inserting the company_id twice. The company_id value is a unique number corresponding to the email (checkbox_email)
Here is part of the code:
Can anyone see the problem?
Cheers,
camcim
I've been playing with this bit of code but can't seem to stop it from inserting the company_id twice. The company_id value is a unique number corresponding to the email (checkbox_email)
Here is part of the code:
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 = "You can update now
Username: $value
Password: $password
Yours sincerely,
Bruce Fleming";
$from = "From: Xer<webmaster@xer.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";
}
}
}
} else if($default == 'true'){
Can anyone see the problem?
Cheers,
camcim