Some error Check It

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
phppick
Forum Commoner
Posts: 57
Joined: Thu Aug 14, 2003 5:59 am

Some error Check It

Post by phppick »

Try to run this code.


-------test.php----

<?

include_once ('httpio.inc');

$formVars = HttpPrm();
$userid = $formVars["userid"];
$password = $formVars["password"];

?>
----END test.php---



----httpio.inc--
<?

function HttpPrm( )
{
global $HTTP_GET_VARS,$HTTP_POST_VARS,$HttpPost;

if ( count($HTTP_POST_VARS) ) return ( $HTTP_POST_VARS );
if ( count($HTTP_GET_VARS) ) return ( $HTTP_GET_VARS );
return ( $HTTP_POST_VARS );
}

function HttpVar( $vKey )
{
global $HTTP_GET_VARS,$HTTP_POST_VARS,$HttpPost;

if ( count($HTTP_POST_VARS) ) return ( $HTTP_POST_VARS[$vKey] );
if ( count($HTTP_GET_VARS) ) return ( $HTTP_GET_VARS[$vkey] );
return ( $HTTP_POST_VARS[$vkey] );
}

?>

--end httpio.inc---
User avatar
PixelMaster
Forum Newbie
Posts: 11
Joined: Sat Aug 16, 2003 11:48 am

Post by PixelMaster »

Had no problems ...

Just a note : you don't need to declare the variables $HTTP_GET_VARS and $HTTP_POST_VARS as global. Just use $_GET and $_POST - they're superglobals, and can be used with out global declarations, anywhere, anytime. Not to mention shorter and easier to type ...
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

what's the error message you get?
Post Reply