PHP Process CGI - Request

When passing CGI variables via the GET method, the special array $_GET[] can be used to access the values as shown in the example code below:

This code is invoked by the following URL where the value of 'select' can be altered:

 

 http://puzzle.sci.csueastbay.edu/~grewe/PHP/ProcessGetRequest.php?select=bye


NOTE: Post requests can be processed similarly using the $_POST[] array to access the data. E.g.

<?php
echo 'Hello ' . htmlspecialchars($_POST["name"]) . '!';
?>

 

ProcessGetRequest.php code:

<?php
//program called with different options set via the select parameter
   $option = $_GET['select'];
printf("option is ".$option."<br>");
   //Option can be to request a request_token or  access_token or access_token
   //  with option specifying the token_secret
   if($option == "hello")
   {
   echo 'hello';
   }
   else if($option == "bye")
   {  echo 'bye'; }
   else
   {  echo 'unknown request'; }
?>
© Lynne Grewe