Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic PHPMail path?

Status
Not open for further replies.

rogerzebra

Technical User
May 19, 2004
216
SE
Hi friends,
I'm back with another issue. Excuse me for my freakvent postings. I'm working on a system with alot of strange requests, wich I obviously have hard time to solve by myself. I hope that you guys are patience, I'm still learning.

Anyhow here's my next problem. I have a submission form which submits a date and register the time based on an existing date in the database when it's executed. Everything works fine, but now they want me to add another feature that when executing this form also send a pdf document in the very same execution, based on the client's name or id.

One problem i see with this is that phpmail needs the full path to the actual document like so,

$mail->AddAttachment("C:/something/something/test3.pdf", 'test3.pdf');

which is a static name path, I need a dynamic name path based on a value from the formpage. In other words a dependend mail path based on a clientID or ClientName value.

Question: Is it possible to use a variable as a value in the path based on ID or Client Name as in a select query with a where clause like so,
Code:
SELECT  Client Name 
FROM table1, table2 
WHERE table1.ID = table2.ID 
AND ClientName ='$ClientName';
I want to change the value test3.pdf to a dynamic value. Is it possible? Or is there a better way to do this?

Thanks for your time and as you can see, the problem I have is rather difficult and needs someone with more experience than I have. All efforts are welcome and much appreciated :)
/rz
 
Sure, you can use a variable in the parameter you pass AddAttachment(). After all, you're just passing the function a string in the first place, and PHP is not very picky whether the string is:

"foo"

or

"fo" . "o"




Want the best answers? Ask the best questions!

TANSTAAFL!!
 
sleipnir,
that was too easy, should trust my instinct before asking.
thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top