if(!isset($_GET['action']))
{
echo "a blank form with out a query";
}
else
{
echo "your search results";
}
?>
or you can morph this
simple class to detect the $_SERVER['REQUEST_METHOD'] and return an array() to use for other actions.
I use this so I can pass query values in the URL automatically.
Example:
This would be a hyperlink on a page. As you see it will go to the index.php or default.php with 2 query arguments.
Home
if($UserInput['app'] == "0" && $UserInput['action'] == "0"){
echo "Welcome to DzSoundNirvana.com's Home page";
}
?>
/*******************************
method.class.php
*******************************/
class Methods{
var $RM;
var $app;
var $action;
var $UserInput = array();
function Methods(){
$this->RM = $_SERVER['REQUEST_METHOD'];
if($this->RM == "GET"){
$this->GetRM();
}
else{
$this->PostRM();
}
}//End function
function GetRM(){
foreach($_GET as $key => $value){
$this->UserInput[$key] = $value;
}
return $this->UserInput;
}//End function
function PostRM(){
foreach($_POST as $key => $value){
$this->UserInput[$key] = $value;
}
return $this->UserInput;
}//End function
}
?>
This is how i call the Method and use the URL query arguments
/****************************
index.php
****************************/
require_once('method.class.php');
$Method = new Methods();
$UserInput = $Method->UserInput;
if($UserInput['app'] == "0" && $UserInput['action'] == "0"){
echo "Welcome to DzSoundNirvana.com's Home page";
}
//You can switch it too for blocking code out
switch($UserInput){
case ($UserInput['app'] == "0" && $UserInput['action'] == "0"):
echo "Welcome to DzSoundNirvana.com's Home page";
break;
case ($UserInput['app'] == "User" && $UserInput['action'] == "Login":
echo "I would build a login page right here";
break;
}
?>