PURPOSE:
Simply to keep PHP from geeking out when an undefined POST, GET, or SESSION variable
is meet, always returning a defined variable. (In particular for use in form check boxes.)
----
USAGE:
getvar( mixed var [, int ])
postvar( mixed var [, int ])
sessionvar( mixed var [, int ])
include_once("get_post.php");
Expecting $_GET["somevar"], use instead getvar("somevar")
Expecting $_POST["somevar"], use instead postvar("somevar")
Expecting $_SESSION["somevar"], use instead sessionvar("somevar")
Example:
$sql = "INSERT INTO tbl_something
SET some_column = " . postvar("checkbox_name",true) . ",
some_other_column = '" . postvar("text_box_name") . "'";
The first argment is the variable name, the second tells the function to return an int (0)
on false.
<?php
/*
----
getvar/postvar - When you just don't know what to expect!
----
Brian Tafoya
briantafoya.com
"Taking over the planet one open source script at a time!"
----
PURPOSE:
Simply to keep PHP from geeking out when an undefined POST, GET, or SESSION variable
is meet, always returning a defined variable. (In particular for use in form check boxes.)
----
USAGE:
getvar( mixed var [, int ])
postvar( mixed var [, int ])
sessionvar( mixed var [, int ])
include_once("get_post.php");
Expecting $_GET["somevar"], use instead getvar("somevar")
Expecting $_POST["somevar"], use instead postvar("somevar")
Expecting $_SESSION["somevar"], use instead sessionvar("somevar")
Example:
$sql = "INSERT INTO tbl_something
SET some_column = " . postvar("checkbox_name",1) . ",
some_other_column = '" . postvar("text_box_name") . "'";
The first argment is the variable name, the second tells the function to return an int (0)
on false.