$_SEVER['REQUEST_METHOD']. Put it all into an arry. Auto.

Information for PHP. Hypertext Preprocessor
Post Reply
dzcadii
Posts: 94
Joined: Sun Mar 01, 2015 4:36 am

$_SEVER['REQUEST_METHOD']. Put it all into an arry. Auto.

Post by dzcadii » Sun Mar 01, 2015 6:37 pm

/****************************************************************************
This is copyright code released under GNU GENERAL PUBLIC LICENSE, GNU LESSER GENERAL PUBLIC LICENSE
Copyright (C) 20008, DzSoundNirvana.com :: http://dzsoundnirvana.com/ ::
email support@dzsoundnirvana.com


see
viewtopic.php?f=16&t=17 for more information
You can use it how ever you want, when ever you want, but you must keep
this section intact (as is)!

If you are below/under the age of 18 read below!

Copyright (C) 20008, DzSoundNirvana.com
email support@dzsoundnirvana.com

If you are under the age of 18 (eighteen) years old you/your parent(s)/guardian(s) must receive written
permission from http://dzsoundnirvana.com/ to use/extract part of this code! If found you/your
parent(s)/guardian(s) may be held responsible/liable! Email support@dzsoundnirvana.com for
more information.

****************************************************************************/



Code: Select all

<?
/*******************************
             method.classs.php
*******************************/
class Methods{
	var $RM; //Remote method
	var $app; //from the URL. Just showing you how to use query strings in a url IE: http://dzsoundnirvana.com?app=0
	var $action; //from the URL. Just showing you how to use query strings in a url IE: http://dzsoundnirvana.com?action=0

//or //from the URL. Just showing you how to use query strings in a url IE: http://dzsoundnirvana.com?app=0&action=0
	var $UserInput=array();
	
	//Constructor
	function Methods(){
	
		$this->RM=$_SERVER['REQUEST_METHOD'];
		if($this->RM=="GET")
		{
			$this->GetRM();
		}
		else
		{
			$this->PostRM();
		}
	}
	
	
	
	
	function GetRM() //$_GET is the Remote Method
	{
		foreach($_GET as $key => $value)
		{
			$this->UserInput[$key]=$value;
		}
		return $this->UserInput;
	}
	
	
	
	
	function PostRM() //$_POST is the Remote Method
	{
		foreach($_POST as $key => $value)
		{
			$this->UserInput[$key]=$value;
		}
		return $this->UserInput;
	}
	
	
	
	
}
?>
now to call the class and use the function
put this where you want to use it

Code: Select all

/*******************************************
                        index.php
*******************************************/
<?
//Defines the method used and formats the $UserIput array IAW it
		$Method = new Methods();
		$UserInput = $Method->UserInput;
			//if URL is domain with out query then redirect to put app & action in
				if(!array_key_exists("app",$UserInput) && !array_key_exists("action",$UserInput)){
					echo "<script type=\"text/javascript\">window.location=\"http://dzsoundnirvana.com/?app=0&action=0\"</script>";
	}
?>

Post Reply