Novahq.net Forum

Novahq.net Forum (https://novahq.net/forum/index.php)
-   phphq.Net Forums (https://novahq.net/forum/forumdisplay.php?f=277)
-   -   Add text to body in phMailer (https://novahq.net/forum/showthread.php?t=41887)

spawny 09-17-2008 05:37 AM

Add text to body in phMailer
 
HI Guys,

i´m new to PHP but i love this phMailer script. My one question after hours of searching the web is how do i add variable outpts to the body of the mail. For example, if i add a new field called $companyname, and i want the message body to start with:

From $companyname

how do i do this?

Scott 09-17-2008 06:26 PM

Here is a good tutorial on php and web forms:
http://www.w3schools.com/php/php_forms.asp

Read the above brief tutorial and then follow below...

As for adding them into the body of the email phMailer sends,
you will want to find the line:
$message.="$yourmessage";

Basically, create a new line two lines above it and replace $yourmessage with your $_POST information.

An example would look like:

$message.="Company Name: $_POST['company_name']";
$message.="\n";
$message.="Another field: $_POST['field_name']";
$message.="\n";
$message.="$yourmessage";

Sorry if this is a bad explanation, im not to good at explaining things.

atholon 09-17-2008 08:32 PM

It can be done other ways but that way is the easiest I know of.

$_POST['company_name']; assumes that you have named the html element company_name.

Make sure you only name the element, don`t put ID's on them...that's an error in XHTML.

$message.="Company Name: ".$_POST['company_name'];
$message.="\n";
$message.="Another field:".$_POST['field_name'];
$message.="\n";
$message.="$yourmessage";

Scott 09-18-2008 09:47 AM

Quote:

Originally posted by atholon
Make sure you only name the element, don`t put ID's on them...that's an error in XHTML.

Where did you hear that?

http://www.w3.org/TR/xhtml1/
Read sec 4.10

Quote:

Note that in XHTML 1.0, the name attribute of these elements is formally deprecated, and will be removed in a subsequent version of XHTML.

atholon 09-18-2008 01:17 PM

XHTML 1.4 does not allow that.

I tried it and it freaked out.

It's lameness does not allow iFrames either which is stupid.

Scott 09-18-2008 06:32 PM

That's extremely odd how they would deprecate the name element for xhtml 1.0 and then deprecate id for 1.4 and bring back name.

I can't comment on the iframe but if ID is going to be taken out i'd like to see some document that states it on w3's website.

Not trying to call you out or anything but I can't find anything and i'd like to know where you heard that from.

atholon 09-18-2008 06:55 PM

I'll find it, I can`t remember what DTD we were using. Let me look into it. I was pretty shocked when I saw it.

atholon 09-18-2008 07:09 PM

Quote:

Line 14, Column 56: element "iframe" undefined.
<iframe src="src" id="fileframe" name="fileframe"></iframe>
I still am not sure if I was using XHTML 1.1. You may be right Scott but I had a heck of a time trying to get it to work with ID's on form elements.

atholon 09-19-2008 12:07 AM

I must be halucinating Scott. I swear I was getting "invalid property" when I assigned an ID to an input field. O-well looks like XHTML 1.1 accepts it.

Sorry to mislead. It still doesn`t support iframes though.
I think it was because I had the ID in caps.
Quote:

Line 9, Column 35: there is no attribute "ID".
<input type="text" name="title" ID="myid"/>


All times are GMT -5. The time now is 01:23 PM.

Powered by vBulletin®