We have 15 guests online
   
PHP Scripts arrow Free PHP Tutorials arrow Free PHP Tutorials arrow PHP Tutorials and Examples arrow PHP 
Free PHP Tutorials arrow PHP Tutorials and Examples arrow PHP

The Basics of multiple pages inside one
User Rating: / 2
PoorBest 

I wasn't really sure what to call this, but I've been doing it forever. So I thought I'd create a little example. This is very basic, it can be expanded too. Below, the p variable will be referring to the current page.

  1. <?php
  2. $p = $_GET['p'];
  3. if ($p==null) //P is null if not specified.
  4. {
  5.      header("Location: ?p=home"); exit; // Redirect to the homepage.
  6. }
  7. elseif ($p=="home") // The homepage
  8. {
  9.      echo "This is the homepage!";
  10. }
  11. elseif ($p=="page2") // page2
  12. {
  13.      echo "This is page #2!";
  14. }
  15. /* It basically checks to see if the GET variable is passed in the URL and displays content accordingly. For example, if you saved this code into index.php, you would have to goto index.php?p=page2 to access page2's contents. You could add more elseif's to the script for more pages.*/
  16. ?>

 

 

Directory Stats

There are 718 listing and 44 categories in our website

Change Language

Bleach Episode
Loans
Mortgage
Rihanna MP3 Download
Credit Card