Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

Dynamic Subject Field

the mail() function

Moderators: macek, egami, gesf

Dynamic Subject Field

Postby RossM » Wed Mar 21, 2012 7:35 am

Hi all,

Bit of a php newbie but getting there !

I have a form which works fine so far. However I would like to make the subject of the email change according to a particular field. Example:

The form has 10 fields, 9 of which must be filled in (have Javascript validation on these that is working ok). The 10th field - a textbox - determines the subject of the email. ie If that field is left blank the email subject is X whereas if something is entered into that box, the email subject is Y. It doesn't matter what is entered or anything like that.

Any advice gratefully received.
RossM
New php-forum User
New php-forum User
 
Posts: 1
Joined: Wed Mar 21, 2012 7:23 am

Re: Dynamic Subject Field

Postby freshnet » Thu Mar 22, 2012 2:45 pm

If your field is called field10 you'll want something like this

Code: Select all
if (!isset($_POST['field10'])||$_POST['field10']=='')
{$subject = 'x';}
else
{$subject = $_POST[field10'];}
User avatar
freshnet
php-forum Active User
php-forum Active User
 
Posts: 252
Joined: Tue Feb 22, 2011 8:19 am
Location: Canada


Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.