Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Rick Hays
Added: Feb 6, 2018 4:57 PM
Modified: Feb 6, 2018 5:01 PM
Views: 25
Tags: php
Returns a Form Get/Post Value
  1. /**
  2.  * GetParam - Returns a Form Get/Post Value
  3.  * @param string $param_name - name of form field.
  4.  * @param string $default [optional] - Default value to pass back if $param_name is blank
  5.  */
  6. function GetParam($param_name, $default=NULL)
  7. {
  8.         global $_POST;
  9.         global $_GET;
  10.         $param_value = "";
  11.  
  12.         if(isset($_POST[$param_name]))
  13.                 $param_value = $_POST[$param_name];
  14.         else if(isset($_GET[$param_name]))
  15.                 $param_value = $_GET[$param_name];
  16.         else if($param_value == "")
  17.                 $param_value = $default;
  18.  
  19.         return $param_value;
  20. }
  21.