Hi.
I am new to PHP and notice that on alot of other sites including this one have a ? after the php and then have text afterward. For example I saw a mysite.com/index.php?id=202 (that is just an example). If you would change the 202 to say 201 it would show a different page. How do you achieve this. Are they using a template page, and just calling a different document or what?






Greg K posted this at 21:32 — 23rd July 2006.
He has: 1,667 posts
Joined: Nov 2003
This is data (arguments) passed the the apge being called. In PHP you can access these values via the predefined $_GET array. In the example you gave, $_GET['id'] would be set to 202. you can have more than one, they are generally given in the format of ?name=value&name=value&name=value
Be sure that you always validate/check the values before just using them in a script. If you go to use any values in things such as URLs, Filenames, SQL statements, etc, make sure that you escape out the values with something like addslashes().
-Greg
[This space intentionally left blank]
Cool Geek Supplies: www.ThinkGeek.com
CptAwesome posted this at 02:46 — 24th July 2006.
He has: 370 posts
Joined: Dec 2004
Most PHP installations do an auto addslashes to $_GET input, so if you echo them to the page or send them to somewhere that won't strip or need the slashes, you will want to stripslashes the output.
<? echo implode('',explode('|','A|W|E|S|O|M|E')); ?>
http://www.free-online-web-tools.com