Using PHP, make a site with pages. www.sitename.com/index.php?page=contact?

  • Thread starter Thread starter l
  • Start date Start date
L

l

Guest
I see sites like this, and I was wondering what are the benefits of doing it like this.

This is the only way I would know of doing it, no doubt, this is wrong, but I am unsure how to do it if I had to.

http://www.sitename.com/viewphoto.php?id=50qa&page=show

I want to know how you could do something like that, not with the whole actual viewing the photo, but just so if it did this it showed photo 50. I don't see the point of doing it like the below, because you may as well just put it in lots of pages, or on the same page. Explain please.

<?php
$page = $_GET['page'];

if($page = "contact") {
?>
Contact me blahbalhaha...
<?
}
?>
 
Tizag.com have some good TUTs on php with the Post/Get function, vairables, if/else etc..... That's where I started to learn php :)
 
This is so you can pass variables to the code. You can also pass them through HTTP post which doesn't show the variables in the URL.

There are many reasons to pass variables through the URL.

For exmaple if you have a social networking site with 1,000's of users you don't want to write or store html pages for each user.

Instead you create one profile page with variables, then you send a variable like ?Userid="Dane_62" and have the php send a sql command like

SELECT * From Porfiles WHERE User_Id = "Dane_62"

then SQl qill return all information about dane_62's profile and php uses that data to replace the variables with dane_62's actual profile data.
 
Back
Top