If you want something you've never had, you must be willing to do something you've never done!

Powered by Blogger.

Php Programming Tutorial "Dnynamic" 1

Cerita Semalam Aaz | 10:38 PM | ,



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 is hello_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.

1 Responses So Far:

Related Post

 
Back To Top