Quick Reference for PHP: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 12: | Line 12: | ||
<nowiki>$qString = $_SERVER['QUERY_STRING'];</nowiki> | <nowiki>$qString = $_SERVER['QUERY_STRING'];</nowiki> | ||
<nowiki>$qString = preg_replace('#[^a-zA-Z0-9_-]#', '', $qString);</nowiki> | <nowiki>$qString = preg_replace('#[^a-zA-Z0-9_-]#', '', $qString);</nowiki> | ||
print "QUERYSTRING= $qString<BR>"; | <nowiki>print "QUERYSTRING= $qString<BR>";</nowiki> | ||
if ($qString == "") $qString = "home"; | <nowiki>if ($qString == "") $qString = "home";</nowiki> | ||
if ($qString == "home") { | if ($qString == "home") { | ||
?><i>Viewing the HOME PAGE</i></a> <? | <nowiki>?><i>Viewing the HOME PAGE</i></a> <?</nowiki> | ||
} elseif ($qString == "other") { | } elseif ($qString == "other") { | ||
?><i>Viewing some other page</i></a> <? | <nowiki>?><i>Viewing some other page</i></a> <?</nowiki> | ||
} | } | ||
Revision as of 13:25, 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<BR>"; if ($qString == "") $qString = "home"; if ($qString == "home") { ?><i>Viewing the HOME PAGE</i></a> <? } elseif ($qString == "other") { ?><i>Viewing some other page</i></a> <? }