Loading...

Dynamic

The real power of PHP lies in its capacity to personalise pages or sending the pages as requested by the user. A personalised page is bette...

The real power of PHP lies in its capacity to personalise pages or sending the pages as requested by the user. A personalised page is better known as a dynamically generated page.
To make PHP aware of what it is supposed to send to the requesting user, the user must send it some information.
Along with the server and name of the page we type in the address bar, the URL, we can also attach what is known as a query string. Like in:
http://localhost/hello_you_3.php?name=John
The text after the ? is the query string. It contains pairs of variable names and variable values. In the above query string we passed the variable name with the value John.
Now we can write PHP code to catch those values and display them to the user. This ishello_you_3.php. Call it as shown above.
<html>
<body>
<?php
echo 'Hello ';
echo $_GET['name'];
?>
</body>
</html>
The $_GET array will hold all the parameters passed in the query string. Lets pass also the user occupation in hello_you_4.php:
<html>
<body>
<?php
echo 'Hello ';
echo $_GET['name'];
echo '<br />I know you are a ';
echo $_GET['occupation'];
?>
</body>
</html>
Call this page with this query string:
http://localhost/hello_you_4.php?name=John&occupation=student
Notice the & between the pairs. You can have as many pairs as you need as long as you delimit them with the ampersand.
PHP Tutorial 2163688365603999472

Post a Comment

emo-but-icon

Home item

ADS

Active Search Results

Popular Posts

Labels

Random Posts

Submit Articles for Free
Authors can submit copyright free articles and enjoy the many benefits provided by ArticleGeek.com.

Flickr Photo