Scriptplayground Network

Scriptplayground Preview
Fireworks CS4 Learning Center

Flash and PHP Bible

The Flash and PHP Bible has been released! The book can be found on Amazon or wherever fine books are sold in your area. This book explains the process of working with PHP in Flash, while creating real world examples that you can actually learn something from.

The Flash and PHP Bible has a dedicated forum for support and comments.

Scriptplayground » tutorials » php » Query Strings

Query Strings

The following article is an explantion on query strings

<?php
http://www.yoursite.com/page.php?url=portfolio
?>


'query string' is the ?url=portfolio part in 'page.php?url=portfolio'. url=portfolio 
is called a variable/value pair. You can seperate them by using an '&' ampersand 
EX: 'page.php?var1=gallery&var2=3d'.

That is what a query string is, but how does PHP read this you ask? Read on.



we use the $_GET array!

The GET array is used in place of the original variable.



print $_GET['url'] . '<br />';

print $_GET['id'] . '<br />';

print $_GET['page'] . '<br />';

That is an example $_GET array being printed in PHP



include $_GET['url'];

This is the most common use of query strings, but that example is highlighting an extremely dangerous way of doing it. Check out the Secure Navigation tutorial here for more info.



Now you should understand how Query Strings work.

| Print It |  Follow Scriptplayground on Twitter (@scriptplay)

Comments: Query Strings

 Gixboy  Sun Jan 29, 2006 11:17 pm  
Thank you a lot. This is the first place that I've found, including Barnes and Noble at my downtown mall, that could give me a simple, to-the-point tutorial on query strings in php. This has made my links go a lot faster, and it saves me annoying "Page Cannot Be Displayed"'s. Good job.
 mkeefe  Thu Feb 2, 2006 1:25 am  
Glad that the tutorial helped you out. It is always nice to hear comments back from the readers. :)
 somone  Mon Oct 8, 2007 7:11 am  
hi, thanks for help
Add a comment
Name:
Website:
Comment:
Please note: Offensive comments, flaming and spamming is not permitted on this site and your comment will be deleted immediately.

HTML is not allowed.

Please provide all comments in English so that others can help you. A common helper in this is to use an online translator.

As a security measure your ip will be recorded.
 
Anti-Robot Check:

Enter the key you see above.

What is this?: This extra test has been added due to the recent explosion of spam.
 
Google