[PHP] executeing another files code
Hey all, Heres my problem, I have this written in email.fff # Start file ## Hi $firstname $lastname, We have recieved your request for support. We will get back to you shortly. Regards, $sitename P.S below is the message you submitted: $message # End file ## Question is: How can I get the file in my php script and fill in those variables then send the above email message. I know how to open a file via fread/file I now how to do the mail() etc... Just a little confused Thanks, Ryan -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.289 / Virus Database: 265.4.5 - Release Date: 12/3/2004 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] executeing another files code
Ryan A wrote: Hey all, Heres my problem, I have this written in email.fff # Start file ## Hi $firstname $lastname, We have recieved your request for support. We will get back to you shortly. Regards, $sitename P.S below is the message you submitted: $message # End file ## Question is: How can I get the file in my php script and fill in those variables then send the above email message. I know how to open a file via fread/file I now how to do the mail() etc... Just a little confused Don't execute it, it's expensive. Simply read the file in a string and replace all occurences that you need: $s = str_replace( array('$firstname', '$lastname', '$sitename', '$message'), array($firstname, $lastname, $sitename, $message), $s); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] executeing another files code
Marek Kilimajer wrote: Ryan A wrote: Hey all, Heres my problem, I have this written in email.fff # Start file ## Hi $firstname $lastname, We have recieved your request for support. We will get back to you shortly. Regards, $sitename P.S below is the message you submitted: $message # End file ## Question is: How can I get the file in my php script and fill in those variables then send the above email message. I know how to open a file via fread/file I now how to do the mail() etc... Just a little confused Don't execute it, it's expensive. Simply read the file in a string and replace all occurences that you need: $s = str_replace( array('$firstname', '$lastname', '$sitename', '$message'), array($firstname, $lastname, $sitename, $message), $s); actually, as far as I see, that should be equally expensive as eval()'ing it :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] executeing another files code
M. Sokolewicz wrote: Marek Kilimajer wrote: Ryan A wrote: Hey all, Heres my problem, I have this written in email.fff # Start file ## Hi $firstname $lastname, We have recieved your request for support. We will get back to you shortly. Regards, $sitename P.S below is the message you submitted: $message # End file ## Question is: How can I get the file in my php script and fill in those variables then send the above email message. I know how to open a file via fread/file I now how to do the mail() etc... Just a little confused Don't execute it, it's expensive. Simply read the file in a string and replace all occurences that you need: $s = str_replace( array('$firstname', '$lastname', '$sitename', '$message'), array($firstname, $lastname, $sitename, $message), $s); actually, as far as I see, that should be equally expensive as eval()'ing it :) eval has to look for more tokens and is less secure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] executeing another files code
Marek Kilimajer wrote: M. Sokolewicz wrote: Marek Kilimajer wrote: Ryan A wrote: Hey all, Heres my problem, I have this written in email.fff # Start file ## Hi $firstname $lastname, We have recieved your request for support. We will get back to you shortly. Regards, $sitename P.S below is the message you submitted: $message # End file ## Question is: How can I get the file in my php script and fill in those variables then send the above email message. I know how to open a file via fread/file I now how to do the mail() etc... Just a little confused Don't execute it, it's expensive. Simply read the file in a string and replace all occurences that you need: $s = str_replace( array('$firstname', '$lastname', '$sitename', '$message'), array($firstname, $lastname, $sitename, $message), $s); actually, as far as I see, that should be equally expensive as eval()'ing it :) eval has to look for more tokens and is less secure. hmm... true... forgot about the tokens ;) as for the security. As long as its local and your in control of the message, it'll be safe enough. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] executeing another files code
Hi again, One last question as am a bit confused, using this method: $s = str_replace( array('$firstname', '$lastname', '$sitename', '$message'), array($firstname, $lastname, $sitename, $message),$s); do I *have to* pass 4 arguements? Because I dont really know how many will be passed...the site owner may decide he wants to use just 3 out of 4... eg: he may want to use just $name, $lastname and $submit_date instead of $name, $lastname, $submit_date and message Thanks, Ryan -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.289 / Virus Database: 265.4.5 - Release Date: 12/3/2004 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] executeing another files code
Ryan A wrote: Hi again, One last question as am a bit confused, using this method: $s = str_replace( array('$firstname', '$lastname', '$sitename', '$message'), array($firstname, $lastname, $sitename, $message),$s); do I *have to* pass 4 arguements? you can set default values (eg an empty string) to cover that scenario. I can aslo offer you a third alternative to the very good suggestions already offereed by Marek and Sokolewicz; printf(); -- Raditha Dissanayake. -- http://www.radinks.com/print/card-designer/ | Card Designer Applet http://www.radinks.com/upload/ | Drag and Drop Upload -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php