Click here to Skip to main content
15,910,661 members
Please Sign up or sign in to vote.
1.31/5 (3 votes)
See more:
hi i want know about query string in PHP
is it important query string in php?
Posted
Comments
Richard C Bishop 12-Feb-14 12:39pm    
A query string is a term for adding/passing data in the URL. It is not language specific. What is your question?

1 solution

What is a query string?


Imagine you have a URL:
http://www.mywebsite.com/page.php?id=5&name=php

Then the query string is:
?id=5&name=php

In this case, the query consists of two parts: a key id with value 5, and a key name with value php.

You can access the value of the query string keys using this code:
PHP
$id = $_GET['id'];

The above code gets the value of id, which is 5 in this case.

Is it important?


Yes, it is, because you can use it to pass data from one page to another. But it's not the only possibility to pass data. If your data contains much characters, use POST[^] instead of a query string.

If you want to pass a password, don't pass it using GET (query strings)! You need to pass it through POST, and SSL is a must! SSL creates an encrypted connection between a web browser and a web server. Without SSL, passing passwords through POST is the same as through GET, because the POST data is also unencrypted. But with SSL, GET data is still unencrypted (but POST data is encryped), that's why you need POST for passwords.
 
Share this answer
 
v3
Comments
Mahshid Fallah 12-Feb-14 14:00pm    
thanks for your Description
i have one question :
when i use the cookie or Login by forum in website...
i haven't query string in url ! why?
Thomas Daniels 12-Feb-14 14:19pm    
For a login, data is transferred using POST, so there is nothing in the query string. And when using a cookie, the data is stored in a file on your computer, so there is also nothing in the query string.
Mahshid Fallah 12-Feb-14 15:24pm    
so how we can have query string in url ?!
Thomas Daniels 13-Feb-14 11:44am    
You can have a query string in a URL like this:
http://www.mywebsite.com/path.php?id=5&name=php
In this case, ?id=5&name=php is the query string.
Mahshid Fallah 14-Feb-14 8:18am    
no no no
i mean when i have a link my site ..my site url don't query string
i can send my mean??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900