Quick Reference for PHP: Difference between revisions

From Free Knowledge Base- The DUCK Project
Jump to navigation Jump to search
No edit summary
No edit summary
Line 10: Line 10:


   <?
   <?
     $qString = $_SERVER['QUERY_STRING'];
     <nowiki>$qString = $_SERVER['QUERY_STRING'];</nowiki>
     $qString = preg_replace('#[^a-zA-Z0-9_-]#', '', $qString);
     <nowiki>$qString = preg_replace('#[^a-zA-Z0-9_-]#', '', $qString);</nowiki>
     print "QUERYSTRING= $qString<BR>";
     print "QUERYSTRING= $qString<BR>";
     if ($qString == "") $qString = "home";
     if ($qString == "") $qString = "home";

Revision as of 13:24, 18 April 2014

Redirect with PHP

See also: PHP Function Reference

 <?
   header('Location: http://members.robotz.com/');
 ?>

Read Query String

 <?
   $qString = $_SERVER['QUERY_STRING'];
   $qString = preg_replace('#[^a-zA-Z0-9_-]#', '', $qString);
   print "QUERYSTRING= $qString
"; if ($qString == "") $qString = "home"; if ($qString == "home") {  ?>Viewing the HOME PAGE</a> <? } elseif ($qString == "other") {  ?>Viewing some other page</a> <? }