[PHP] Joining fixed text to a SUBJECT variable

2013-03-02 Thread Michael CALDER


-- G'day ,

I have a basically simple problem the solution to which has eluded me
for several days.

I have a form being handled by a .php file.

I want the received email sent by the form to have as its SUBJECT the
combination of the form name RVRA Contact Form -  and the MESSAGE
SUBJECT as chosen in the form drop down box.

Here is the current contact2.php file - but the SUBJECT only shows as
RVRA Contact Form -

?php

// get posted data into local variables
$EmailAddress = Trim(stripslashes($_POST['EmailAddress']));
$EmailTo = mikecal...@optusnet.com.au;
$Subject = RVRA Contact Form - ,$MessageSubject;
$Name = Trim(stripslashes($_POST['Name']));
$EmailAddress = Trim(stripslashes($_POST['EmailAddress']));
$YesNo = Trim(stripslashes($_POST['YesNo']));

$MessageSubject = Trim(stripslashes($_POST['MessageSubject']));
$Message = Trim(stripslashes($_POST['Message']));

// send email
if(!isset($_REQUEST['identiPIC_selected'])){exit;}

$identiPIC[1] = Bird;
$identiPIC[2] = Logo;
$identiPIC[3] = Flower;

if($_REQUEST['identiPIC_selected'] !== $identiPIC){print meta
http-equiv=\refresh\ content=\0;URL=error-pic.html\; exit;}




// prepare email body text
$Body = ;

$Body .= Name: ;
$Body .= $Name;
$Body .= \n;

$Body .= EmailAddress: ;
$Body .= $EmailAddress;
$Body .= \n;

$Body .= RVRA Member;
$Body .= $YesNo;
$Body .= \n;



$Body .= Message Subject: ;
$Body .= $MessageSubject;
$Body .= \n;

$Body .= Message: ;
$Body .= $Message;
$Body .= \n;


// send email
$success = mail($EmailTo, $Subject, $Body, From: $EmailAddress);

// redirect to success page
if ($success){
print meta http-equiv=\refresh\ content=\0;URL=thanks.html\;
}
else{
print meta http-equiv=\refresh\ content=\0;URL=error-pic.html\;
}

?

The critical line is line 4:

$Subject = RVRA Contact Form - ,$MessageSubject;

Can anyone please advise or point me in the right direction for
instructions on how to combine the fixed text with the variable
$MessageSubject.

Thanks

Mike

Michael CALDER
73/81 Willandra Road,
CROMER NSW 2099
02 9981 6327


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Joining fixed text to a SUBJECT variable

2013-03-02 Thread Michael CALDER



G'day ,

Thanks to you both I have muddled through. The actual answer was

$Subject = RVRA Contact Form - .$_POST['MessageSubject'];

I had tried something like that but I used a comma instead of the period.

And, yes, I was getting error messages Undefined variable on line 6. 
etc but was too dumb to work out the fix :-(


The other bloke talking strine on 'tamouse' has given me plenty to work 
on. I see you were also talking about spring chickens and autumn 
turkeys. I reckon I am almost a dodo at 82 :-)


Thanks again to you all.

Cheers

Mike

Michael CALDER
73/81 Willandra Road,
CROMER NSW 2099
02 9981 6327

On 02/03/13 23:03, Maciek Sokolewicz wrote:

On 2-3-2013 12:23, Lester Caine wrote:

Michael CALDER wrote:

$Subject = RVRA Contact Form - ,$MessageSubject;

Can anyone please advise or point me in the right direction for
instructions on how to combine the fixed text with the variable
$MessageSubject.


The quick fix is simply
$Subject = RVRA Contact Form - .$MessageSubject;

but
$Subject = RVRA Contact Form - ,$MessageSubject;
should work, what is the error? ... you don't actually want the ','

$Subject = RVRA Contact Form - $MessageSubject;
Should work as well



No it shouldn't, unless you have register_globals turned On. Which most
hosts don't (and shouldn't) do.

The problem is the simple fact that the variable $MessageSubject is not
defined until 4 lines farther into the script. Changing the variable to
$_POST['MessageSubject'] (and concatenating using the concatenation
operator (the period: '.' )) should fix this for you.

If Michael had E_NOTICE errors turned on, he would see an E_NOTICE:
Undefined variable on line 6. Apparently, he doesn't show E_NOTICEs
either.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php