November 15, 2010
What is wrong with my function? (new to user defined functions)
Question by Mitchell Klein
I am trying to post from a previous page with a form on it, and rather then typing out the code over and over again i tried making a function for it, it didnt work. thanks in advance
function postORempty($field){
isset($_POST[$field]) ? $_POST[$field] : "";
}
$szFname= postORempty('fname');
Answer by Starx
You haven’t returned any value
function postORempty($field){
return isset($_POST[$field]) ? $_POST[$field] : "";
}
$szFname= postORempty('fname');