It is a piece of the script where the problem is.
$dfg is declared in the first line.
I would like to search the content of a field. This field contains AND plain text AND variables like $dfg.
I would like to use it to send 1 mail at a time, but the content of the mail could be different depending on the values that I give to the variables at the time of sending.
*****SCRIPT*****
$dfg="FF";
$vmailtxtnr=310;
$sql5= "select * from mailtekst
where mailtxtnr='$vmailtxtnr'";
$res5 = mysql_query($sql5);
if ($row5 = mysql_fetch_array($res5)) {
do {
$vmailsubject=$row5["mailsubject"];
$vmailtxt=$row5["mailtxt"];
}
while ($row5 = mysql_fetch_array($res5));
}
else {
print "";
}
$to="$a";
$subject="$b $vmailsubject";
$message="$vmailtxt";
$headers="$e";
mail($to, $subject, $message, $headers);
*****END SCRIPT*****
Maybe it helps when I post the complete script:
TEST.PHP
<?php
include ("dbconnect.php");
include ("variabelenvoormail.php");
include ("mailtest.php");
?>
VARIABELENVOORMAIL.PHP
<?php
include("dbconnect.php");
$sql= "select klantnummer from stagehis
where inzetnummer='$vinzetnummer'";
$res = mysql_query($sql);
if ($row = mysql_fetch_array($res)) {
do {
$vklantnummer=$row["klantnummer"];
$vdatum=$row["datum"];
$vtijd=$row["tijd"];
}
while ($row = mysql_fetch_array($res));
}
else {
print "";
}
$sql2= "select * from stagehis
left join klanten
on stagehis.klantnummer = klanten.klantnummer
where inzetnummer='$vinzetnummer'";
$res2 = mysql_query($sql2);
if ($row2 = mysql_fetch_array($res2)) {
do {
$vemailontvanger=$row2["emailfact"];
$vklantnaam=$row2["naamkl"];
$vklantadres=$row2["adreskl"];
$vklantpc=$row2["pckl"];
$vklantwpl=$row2["woonplkl"];
$vfactnaam=$row2["naamfact"];
$vfactadres=$row2["adresfact"];
$vfactpc=$row2["pcfact"];
$vfactwpl=$row2["woonplfact"];
$vemailkl=$row2["emailkl"];
$vtelefoonkl=$row2["telefoonkl"];
$vmobnumkl=$row2["mobnumkl"];
$vleeftijdkl=$row2["leeftijdkl"];
$vemailfact=$row2["emailfact"];
$vtelefoonfact=$row2["telefoonfactfact"];
}
while ($row2 = mysql_fetch_array($res2));
}
else {
print "";
}
$sql3= "select * from stageinfo
left join stagehis
on stageinfo.functienummer = stagehis.functienummer
where inzetnummer='$vinzetnummer'";
$res3 = mysql_query($sql3);
if ($row3 = mysql_fetch_array($res3)) {
do {
$vfunctie=$row3["functie"];
$vfunctienummer=$row3["functienummer"];
}
while ($row3 = mysql_fetch_array($res3));
}
else {
print "";
}
$sql4= "select * from stageinfo
left join bedrijf
on stageinfo.bedrijfsnummer = bedrijf.bedrijfsnummer
where functienummer='$vfunctienummer'";
$res4 = mysql_query($sql4);
if ($row4 = mysql_fetch_array($res4)) {
do {
$vbedrijfsnaam=$row4["bedrijfsnaam"];
$vtelnumalg=$row4["telnumalg"];
$vbezoekstraat=$row4["bezoekstraat"];
$vbezoekpc=$row4["bezoekpc"];
$vbezoekplaats=$row4["bezoekplaats"];
$vbezoekland=$row4["bezoekland"];
$vnaamcp=$row4["naamcp"];
$vfotogr=$row4["fotogr"];
$vlunch=$row4["lunch"];
$vgeheim=$row4["geheim"];
$vemailcp=$row4["emailcp"];
}
while ($row4 = mysql_fetch_array($res4));
}
else {
print "";
}
$sql5= "select * from mailtekst
where mailtxtnr='$vmailtxtnr'";
$res5 = mysql_query($sql5);
if ($row5 = mysql_fetch_array($res5)) {
do {
$vmailsubject=$row5["mailsubject"];
$vmailtxt=$row5["mailtxt"];
}
while ($row5 = mysql_fetch_array($res5));
}
else {
print "";
}
?>
MAILTEST.PHP
<?php
/* subject */
$subject = "$vinzetnummer $vmailsubject";
$message= $vmailtxt;
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "To: $vemailontvanger, \r\n";
$headers .= "From:
www.xxx.nl <info@xxx.nl>\r\n";
$headers .= "Cc: \r\n";
$headers .= "Bcc:
info@xxx.nl\r\n";
/* and now mail it */
mail($to, $subject, $message, $headers);
?>
I would like to execute test.php?vinzetnummer=1&vmailtxtnr=1
In the table mailtekst is a record which contains:
mailtxtnr=1
mailtxt=Dear $vklantnaam
mailsubject=Confirmation
So that is processes like Dear Mr. Johnson, if $vklantnaam contains "Mr. Johnson"
And that does not happen!