Posted By

alli14404 on 10/28/08


Tagged

get post functions clean referer


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

vali29


Clean & Grab POST/GET/Referer Variable functions


 / Published in: PHP
 

This set of functions makes it quicker for me to code, might be useful to someone else =]

  1. function clean($var){
  2.  
  3.  
  4. }
  5.  
  6. function grab_postvar($index, $clean = true){
  7.  
  8. return (isset($_POST[$index]) && !empty($index)) ? (($clean) ? clean($_POST[$index]) : $_POST[$index] ) : false ;
  9.  
  10. }
  11.  
  12. /* Usage: $post_variable = grab_postvar("id"); | Returns the variable else returns boolean false */
  13.  
  14.  
  15. function grab_getvar($index, $clean = true){
  16.  
  17. return (isset($_GET[$index]) && !empty($index)) ? (($clean) ? clean($_GET[$index]) : $_GET[$index] ) : false ;
  18.  
  19. }
  20.  
  21. /* Usage: $get_variable = grab_getvar("id"); | Returns the variable else returns boolean false */
  22.  
  23.  
  24. function grab_referer($default = NULL){
  25.  
  26. return (isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER'])) ? clean($_SERVER['HTTP_REFERER']) : ((is_null($default)) ? '/' : $default ) ;
  27.  
  28. }
  29.  
  30. /* Usage: $referer_url = grab_referer("index.php"); */

Report this snippet  

You need to login to post a comment.