PHP tutorial: Query string

Query string

The information can be sent across the web pages. This information is called query string. This query string can be passed from one page to another by appending it to the address of the page. You can pass more than one query string by inserting the & sign between the query strings. A query string can contain two things: the query string ID and its value. The query string passed across the web pages is stored in $_REQUEST, $_GET, or $_POST variable. Whether you passed the query string by using GET or POST method, it is stored in $_REQUEST variable. If you want to access the query string you can use these variables. You should note that whether the query string is passed by the GET or POST method it can be accessed by using the $_REQUEST variable. If you want to use $_GET variable to access the query string the form method need to be GET. Also you can use $_POST variable to get the query string if the form method is POST.

In the following example, the query strings username and email(the names of texboxes) are passed from a page called login.php to another page called welcome.php when you click the submit button.

<title>Login form</title>
<form action="welcome.php" method=”get”>
<td>User name:</td><td> <input type="text" name="username" ></td>
<td>E-mail: </td><td><input type="text" name="email" ></td>
<td><input type="submit" name="sub" value="submit"></td>

echo "<strong>Welcome ".$_GET['username']. "!</strong><br/>";
echo "Please remember this e-mail: ".$_GET['email']. " for later use.";


zdzsfdsfxdfdgdf comment



fff comment




This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.