ghost2012;10910646 wrote:djjjozsi
I do appreciate that but i'm lost on how to apply it for use.
So, i was showing you how to build a function to create a string using the $_POST index name.
if you have a $POST variable called $POST["customerCode"], if you wanted to add to a mail message, you need to check if its not null , in that case add to the mail string.
if(!empty($_POST["customerCode"]))
$pfw_message.="Customer Code: " .$_POST["customerCode"];
then you have to use this method to add the other variables such as $_POST['zipcode'] ... ect.
if(!empty($_POST["zipcode"]))
$pfw_message.="zipcode: " .$_POST["zipcode"];
See, this technique takes hours to build a mail message, a shorter is to make a function:
function add_if_not_null($postvar,$title)
{
if(!empty($_POST["$postvar"]))
return ($title.":". htmlspecialchars($_POST["$postvar"])."\n");
}
i passed two arguments, first will determine the $POST array's name, and the 2th will be the title in the mail message. This checks if that $POST index is not empty , then return from the function with a string (Title: value). htmlspecialchars function will change the harmful scripts into html codes.
How you call this function?
$pfw_message .= add_if_not_null("item001","Item 1");
.= means include the following string values to the variable on the left.
There are simplier ways, but first build simple functions to learn how
these things going.
on www.php.net search for the mentioned functions and operators to read better explanations.
hello, jjozsi.