Hi, I want the title "Great Man" in the below url to display in the middle of the redirect page : URL : http://www.mydoamain.com/redirect.php?q=Great Man Code (markup): But cannot get it to display anywhere. Not even in the title tag. Help will be appreciated. Thanks.
Some advice on that... use htmlspecialchars on that output: <?php echo htmlspecialchars($_GET['q']) ?> Otherwise people could pass javascript or other code in your $_GET data to make cross site scripting exploits. Remember, ALL user input is suspect and should be sanitized -- be it for passing to a database or sent back to the browser in the result. I'd probably also skip the "variable for nothing" if you are only using it once. If you are going to use it more than once, THEN put it into a variable. As Uncle Red often said, "You guys know me... Safety forced!"
Very good points to note, but all the OP asked was how to pull from the URL, and than said he just was trying to echo it to make sure it worked, I assumed that he would not use malicious code on his own platform. However I do agree we should go ahead and tell them everything if were going to bother telling them anything.
I assumed he wouldn't have the slightest idea how to write secure code since he asked such an elementary question.
That's my take on it too -- the question shows someone starting out and a bit green around the gills, to even MENTION blindly dumping out the value with echo... from $_GET? Herpafreakingderp in my book. Of course, if you only care about NEW php and have kicked 5.3/earlier to the curb, we don't need to say echo since the <?= shorttag now ALWAYS exists. <?= htmlspecialchars($_GET['q']) ?> Code (markup): Should work in 5.4/newer regardless of the shorttags setting.