Hello All,
ok, so i have this function that i use most of the time to send email (contact forms, etc) the problem i have is that the function sends out all the fields of the form even if the field of the form was not filled up, how can i make it to send out only the fields that were filled up by the user? below is my function;
function Key2Name($key){
return strtoupper(str_replace("_"," ",$key));
}
$txt = "";
if($REQUEST_METHOD == "POST") {
$content=$_POST;
$total=count($_POST);
reset($content);
while (list($key, $val) = each($content)) {
$txt.= "".Key2Name($key).": $val
";
}
if(($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) ) {
mail("me@myemail","New contact form submission",$txt,"From: $email");
print "<strong>Thank you, the information was submitted</strong>"; }
else {
echo "<font color=\"red\"><strong>Security code incorrect!, try again.</strong></font>";
}
}
thank you to all in advance for any help.