Difference between revisions of "Quick Reference for PHP"

From Free Knowledge Base- The DUCK Project: information for everyone
Jump to: navigation, search
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 15: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> <? }