Web Hosting with Php: What's the? in the Url? (cont.)

Contributed by Deb Powers



watchful owl

WHO's watching your Website? Try the Cool Free Website Monitor!

We've been using this awesome webmaster service for a while now and we absolutely love it... In two minutes, your website will be under the watchful eye of a distributed node network. Very cool for you!

http://acme-web-design.info/site-monitor.php


<center><h1>Your background color is <? php echo $color;? >. </hl><center>

<center><h2>Your text color is <? php echo $texcolor;? >. </h2></center>

</body>

</html>

Save the file with the name snippet.php.

Upload the file to your server.

In the address bar of your web browser, type:

http://www.<yourdomain>.com/snippet.php? color=red&texcolor=white

Try it a few more times, replacing 'red' and 'white' with other colors.

Explanation of PHP Variables in the URL

The script above demonstrates one of the powerful features of PHP - the ability to dynamically define variables in your web page through the URL. The '? ' and '&' characters in the URL tell the server 'this is a php script, and these variables fit into this page'. In this case, all we did was define the background and text colors for the page BEFORE it loads. More advanced scripts combine with forms and databases to create entire dynamic pages by calling variables from the URL.

Can I upload my own PHP scripts to my web hosting servers?

If you'd like to write your own scripts, there are a lot of great tutorials on the web to help you get started. One of the best resources is at www.webmonkey.com.


« Prev




boxtop

Copy and paste this code:

Linking Hands

boxbottom
Acme Web Design Info Logo Everything your mother didn't teach you about the web Hand pulling Acme Web Design package