Forum Moderators: coopster
Instead of doing a two step process, where I set the value to a variable, and using the variable in the mail command, I'm trying to use the value straight in the mail command.
From this:
$bodyvariable=$_REQUEST["bodyvariable"];
mail("to","sub","$bodyvariable","from");
To something like this:
mail("to","sub","$_REQUEST[\"bodyvariable\"]","from");
The problem is, I'm getting a parse error. Is a one-step process not allowable?
Thanks
mail("to","sub",$_REQUEST["bodyvariable"],"from");
that should work, however it's usually considered a good idea to do some kind of input validation before using the data. and if you wanted user input for the from field, for example, you would definately need to validate otherwise you'd be vunerable to email injection.
Not sure if it's too important in this case since the variable is the mail body.
Anyhow, when working with array values, here's what to consider:
$array = array('key' => 'value');
$array[key] // bad, key assumed to be a constant named key
$array['key'] // good
$array["key"] // good
when used within double-quotes
"$array[key]" // good
"{$array['key']}" // good
"{$array[key]}" // bad, key assumed to be a constant named key
Like others have said, you don't need the quotes around the $_REQUEST variable, but if you do want to use them, either use "$_REQUEST[bodyvariable]" or "{$_REQUEST['bodyvariable']}"