LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-10-2003, 11:40 PM   #1
BigFred
LQ Newbie
 
Registered: Sep 2003
Location: Mount Isa, Queensland, Australia
Distribution: RedHat
Posts: 13

Rep: Reputation: 0
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

Last edited by BigFred; 09-11-2003 at 07:36 AM.
 
Old 09-11-2003, 04:12 AM   #2
Andy@DP
Member
 
Registered: Aug 2003
Posts: 208

Rep: Reputation: 30
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.

Last edited by Andy@DP; 09-11-2003 at 04:16 AM.
 
Old 09-11-2003, 07:35 AM   #3
BigFred
LQ Newbie
 
Registered: Sep 2003
Location: Mount Isa, Queensland, Australia
Distribution: RedHat
Posts: 13

Original Poster
Rep: Reputation: 0
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
 
Old 09-11-2003, 07:54 AM   #4
BigFred
LQ Newbie
 
Registered: Sep 2003
Location: Mount Isa, Queensland, Australia
Distribution: RedHat
Posts: 13

Original Poster
Rep: Reputation: 0
This looks like the thing I wish to do.

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

Anyone sugest any improvements, please. BF
 
Old 09-11-2003, 07:58 AM   #5
Andy@DP
Member
 
Registered: Aug 2003
Posts: 208

Rep: Reputation: 30
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.
 
Old 09-12-2003, 09:10 AM   #6
BigFred
LQ Newbie
 
Registered: Sep 2003
Location: Mount Isa, Queensland, Australia
Distribution: RedHat
Posts: 13

Original Poster
Rep: Reputation: 0
Thanks,

I'll let you know how I get on. BF
 
Old 09-19-2003, 10:02 AM   #7
BigFred
LQ Newbie
 
Registered: Sep 2003
Location: Mount Isa, Queensland, Australia
Distribution: RedHat
Posts: 13

Original Poster
Rep: Reputation: 0
Works well, thanks for the help. BF
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP form-trouble adding extra fields fdlx4000 Programming 6 09-24-2005 09:27 AM
Can't enter text in certain Java text fields TheBelush Linux - Software 4 04-27-2005 05:29 PM
set focus on a text form of a web page? codec Programming 2 12-31-2004 04:32 AM
Appending Text Files From Bash Script alts Programming 3 11-18-2004 06:36 PM
search for specific text in fields using awk Helene Programming 2 04-23-2004 12:13 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration