I have a page that makes a call to an outside php page that creates a txt file and stores it on the server, attaches the file to an email then deletes it.
Everything works except the bolded line of:
exec('/home/terra/public_html/CreateDealerCatalogDB.php?ID=$DealerID&save=1');
I initially tried using this:
<img src='/CreateDealerCatalogDB.php?ID=$DealerID&save=1' width='1' height='1'>
which worked but only after submitting twice as the <img> tag got executed AFTER the php.
Everything I read says the "exec()" function is what I want to do but I can't for the life of me figure out why it doesnt work.
Heres what I have:
$text = "$TransDesc \n\n $CustomizationInfo"; if($includeLogo == "1"){$path_of_logo = "../../images/dealers/dealerLogos/hires/$LogoHi";} if($includeDB == "1"){ //create a copy of catalogDB to attach exec('/home/terra/public_html/CreateDealerCatalogDB.php?ID=$DealerID&save=1'); $path_of_db = "../../images/dealers/db$DealerID.csv"; } $from = "info@xxx.com"; $subject = "Dealer Order"; $email = "info@xxx.com"; $to = "info@xxx.com"; include_once('../../PEAR/PEAR/Mail.php'); include_once('../../PEAR/PEAR/Mail/mime.php'); $message = new Mail_mime(); $message->setTXTBody($text); //$message->addAttachment($path_of_logo); $message->addAttachment($path_of_db); $body = $message->get(); $extraheaders = array("From"=>$from, "Subject"=>$subject,"Reply-To"=>$email); $headers = $message->headers($extraheaders); $mail = Mail::factory("mail"); $mail->send($to, $headers, $body); if($includeDB == "1"){ //destroy created db exec('/home/terra/public_html/CreateDealerCatalogDB.php?ID=$DealerID&delete=1');
And again the flow is:
- My php page executes an outside file with the path of /home/terra/public_html/CreateDealerCatalogDB.php?ID=$DealerID&save=1'
- outside file creates a txt file on my server
- php page attaches file to mail.sends
- php file deletes txt file
Any help will be greatly appreciated as i've struggled for an entire day on this already.