lshstech Posted February 7, 2008 Share Posted February 7, 2008 Hi I have created a PHP front end to my Filemaker database that allows a user to enter details into a form that adds it to the database and then displays a confirmation page with the details that have been entered. In the confirmation page code I have added the following code that sends an email with details from the record displayed in the confirmation page. Here is the code below: ----------------------------------------------------------------------------------------------------------------------- <?php ini_set("SMTP","10.99.240.12"); ini_set("smtp_port",25); mail( $to = '[email protected]', $subject = 'Network logon: '. $record->getField('Network logon', 0), $message = 'E1 Username:'. $record->getField('E1 Username', 0), $headers = 'From: [email protected]'."\r\n" ); ?> ---------------------------------------------------------------------------------------------------------------------- I would like to add more data from fields in the record in the confirmation php page but this is where I get syntax errors. I have tried adding the following line below the highlighted line in my code. $message = 'Details:'. $record->getField('details', 0), When this is entered I get a syntax error and no email is sent. The PHP code sends an email fine without this line added but I would like add multiple fields from my databse record to the message part of the email. Any help will be well appreciated! Thanks Simon Link to comment https://forums.phpfreaks.com/topic/89883-multiple-message-strings-needed-using-the-mail-function/ Share on other sites More sharing options...
aschk Posted February 7, 2008 Share Posted February 7, 2008 Yeah because the mail function ONLY takes 4 parameters, NOT 5. Hence your syntax error. What about $message = 'E1 Username:'. $record->getField('E1 Username', 0).'Details:'. $record->getField('details', 0), Or you could construct the message OUTSIDE of the mail function... Link to comment https://forums.phpfreaks.com/topic/89883-multiple-message-strings-needed-using-the-mail-function/#findComment-460640 Share on other sites More sharing options...
lshstech Posted February 7, 2008 Author Share Posted February 7, 2008 Hi thanks for your help, I found that the following code works: $message = 'E1 Username:'. $record->getField('E1 Username', 0). 'Details:'. $record->getField('Details', 0), This emails me both fields which is great. Do you know I can put a line break in so that I can separate the data onto different lines in a email message? i.e. E1 Username: username here Details: Problem details here Cheers Simon Link to comment https://forums.phpfreaks.com/topic/89883-multiple-message-strings-needed-using-the-mail-function/#findComment-460665 Share on other sites More sharing options...
aschk Posted February 7, 2008 Share Posted February 7, 2008 Put a \n in that string, unless you're using an html format in which case you need a <br> I recommend constructing your message outside the mail function, because i almost certainly guarantee this is going to grow and become unmanageable in it's current format. Link to comment https://forums.phpfreaks.com/topic/89883-multiple-message-strings-needed-using-the-mail-function/#findComment-460668 Share on other sites More sharing options...
lshstech Posted February 7, 2008 Author Share Posted February 7, 2008 Hi thanks for your help it now works fine. I can see that it will soon get very unmanageable after adding some more fields in this string. So what is the syntax for building the message string outside the function? thanks Simon. Link to comment https://forums.phpfreaks.com/topic/89883-multiple-message-strings-needed-using-the-mail-function/#findComment-460674 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.