
Quick Links

Quick Links
Categories
Categories

Top Submitters

Top Submitters

Random Tutorials

Random Tutorials
|
|

Announcments

Announcments
Welcome to Tutorial System!
courtesy of www.ipsbeyond.com & www.invisionize.com
|

PHP Switch Function
Tutorial Information
|
Name: |
PHP Switch Function |
Submitter: |
NickTheGreek |
Category: |
IPS Tutorials |
|
Submitted: |
17 Sep 2007 |
Updated: |
17 Sep 2007 |
Views: |
517 |
Rating: |
This tutorial is unrated. |
|
|
|
Description: Learn how to use the Switch function on your site. |
Tutorial Instructions
|
This tutorial will allow you to have one file with multiple pages, just like IP.Board... Lets get started:
Now you need your base file (index.php) this will hold the switch command, so open up your favourite editor and paste the following code:
CODE <?php
//----------------------------------- // Index.php Extension //-----------------------------------
$act = $_GET['act']; switch($act) {
//----------------------------------- // Pages //-----------------------------------
case "page1": @include('page1.php'); break;
case "page2": @include('page2.php'); break;
//----------------------------------- // Home page //-----------------------------------
default: @include('home.php'); break; }
?>
Now you can change the act text in here to whatever you want - "$act" - if you leave it the page will be "index.php?act=page1". Now you can change page1 & page2 to whatever you want the pages to be called e.g. "index.php?act=aboutus". Now if you don't want your files to be called page1.php etc, you can change these e.g. "@include('aboutus.php');". Now the default lines are which page your site will load if you type in index.php with no extension, this would be known as the home page.
Now save this file as "index.php".
Now you need to program the included files, so you need to add information into all the files you stated e.g. home.php, page1.php & page2.php. So simply make new files and put in your page's information. You can use HTML only if you wish or if your more advanced you can put PHP into the page.
So now you need to upload all your files. Now you can type in index.php?act=page1 etc...
Remember you can add as many of these act= pages as you want!!!
Hope this tutorial helps, if you are still unsure on how to use this I will be uploading an attachment to the Tutorial's topic, containing all of the necessary files.
-Kindred |
Comments
|
There have been no comments made as of yet. Why not be the first?
|
|