This topic is locked
[SOLVED]

 send or not send email

8/4/2020 12:29:42 PM
PHPRunner General questions
S
shoppy author

Several nurses attend the same patient.

Therefore when something is changed in a dossier an email is send to those nurses.

But sometimes a dossier just need some 'cleaning up' and is an email not nessesary to send.
I made a checkbox that is normaly 'on'. But is an email is not to be send the checkbox is un-checked before saving.
The field name of the checkbox is 'emailbericht'.
AfterEdit



// ********** Send conformation email ************

ini_set('SMTP','smtp.email.com');

$html = true;
// variables

$stuur = $values["emailbericht"];

$from = "me.mail.com";



$subject = "Patient";
$message = 'Bla bla bla';

$message .= 'Bla bla bla' . "<br />" . "<br />";

$message .= 'Administration';
//Headers

$headers = 'From: ' . $website_naam . ' <' . $from . '>' . PHP_EOL;

$headers .= 'X-Mailer: PHP/' . phpversion() . PHP_EOL;

$headers .= 'X-Priority: Normal' . PHP_EOL;

$headers .= ($html) ? 'MIME-Version: 1.0' . PHP_EOL : '';

$headers .= ($html) ? 'Content-type: text/html; charset=iso-8859-1' . PHP_EOL : '';
if ($stuur = 1)// Send the message

{

mail($from, $subject, $message, $headers);

}

else

{

echo "Waarde : $stuur";

}

header("Location: Particulieren_list.php?a=return");

exit();


The problem is that eather way the email is send.

W
wpl 8/4/2020

shoppy,



if ($stuur = 1)// Send the message

{

mail($from, $subject, $message, $headers);

}

else

{

echo "Waarde : $stuur";

}


the problem is that you are assigning 1 to $stuur. What you actually want to do is comparing $stuur to 1 which can be done like so:



if ($stuur == 1)// Send the message

{

mail($from, $subject, $message, $headers);

}

else

{

echo "Waarde : $stuur";

}


Or even more strict (compared items must be equal and of same type):



if ($stuur === 1)// Send the message

{

mail($from, $subject, $message, $headers);

}

else

{

echo "Waarde : $stuur";

}


Regards

S
shoppy author 8/4/2020

Dear WPL,
Thanks a million!!

This worked!