LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   PHP appending form fields and text. (https://www.linuxquestions.org/questions/programming-9/php-appending-form-fields-and-text-91499/)

BigFred 09-10-2003 11:40 PM

PHP appending form fields and text.
 
Hi Folks

Not done a lot of PHP programming, I need some help.

I have a HTML form that I would like to be able to have e-mailed back to me.

I've written a simple form with that has one field for the senders e-mail address and one field for the message.

I'd like to expand this so that there are a number of fields for the sender to complete.

I am looking at how do I append the contents of these fields together and add suitable headings and formatting and then place into the message variable for the e-mail form?

Can anyone give me a small sample, so that I can get the idea and build on it to achieve my desired output.

By way of example I would like fields for Name, Phone, Date Equipment Required, Reason.

I'd love to post an image of the required message, but the forum won't let me. Try looking here http://micrrh.jcu.edu.au/~tom/message.gif

Andy@DP 09-11-2003 04:12 AM

http://uk.php.net/manual/en/function.mail.php

This is the php manual entry for the mail() function. It has some nice examples of how to format the message before sending it off.

Read the user comments below the text as well, they mostly have only good advice!

If you do want a small example of code, I could knock something up. I would have done for this post but if the above is OK then it would have been a waste of time, LOL ;)

Hope this helps.

BigFred 09-11-2003 07:35 AM

Thanks Andy

I'll take a look at that.

But just to expand on my original question a bit following is what I'd like to do:-

I wish to apend some variables, some text and some formatting into one variable.

I would like to join the following:- Usename (text) + username (variable) + newline (formatting) + Phone (text) + phonenumber (variable) + newline (formatting) and so on and assign it all to a variable called message.

The () in the above, are for explanation only, and are not what I wish to include in the final string. BF

BigFred 09-11-2003 07:54 AM

This looks like the thing I wish to do.

$message = 'Username ' . $username . "\n" . 'Phone ' . $phonenum . "\n";

Anyone sugest any improvements, please. BF

Andy@DP 09-11-2003 07:58 AM

Not really apart from doing:

$message = "Username $username\nPhone $phonenum\n";

If the string is encased in double quotes put variable names inside and they will be replaced by the variables value, put it in sigle quotes and it will not be evaluated.

Please ask another question if this not clear.

BigFred 09-12-2003 09:10 AM

Thanks,

I'll let you know how I get on. BF

BigFred 09-19-2003 10:02 AM

Works well, thanks for the help. BF


All times are GMT -5. The time now is 09:48 PM.