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');

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!