Nov 21, 2009

Making A One Page Does All Website In Phph

free web hosting
Open Discussion > MODERATED AREA > Tutorials

Making A One Page Does All Website In Phph

cwconline
Hello and Great Day or Night either one.

Have you ever been to a site and seen a index page or any page at all control everything such as

index.php?do=home&action=logout

something similar to the above? Well I am going to show you how easy it is to make this all own your own, and only have to use one web template or design to make it work.

Before we get started you need to go ahead and find the web design that you want to use.

After you find the site you want to use go ahead and save it... and save it like this so we can work together, ok!

Note* We are going to be skipping around a little bit and this probably will be a long tutorial but it is worth it.

1.) Create a New Folder Called site
2.) in the site folder save the page as temp.php
3.) do not move your css or img files into the same folder leave them in the root folder where your index file for your site is.
4.) now we are going to create the index page

CODE


<?php

$page = $_GET["do"]; // this is going to get the page that is being requested
$act = $_GET["action"]; // this is going to be the action that is going to be processed if any.

// We are now going to set where the "do" is going to go.

#######################################
# This is the home page #
#######################################
if( $page == "home" or $page == "main" or $page <= " " ){

include "site/temp.php";
}

#######################################
# This is the About Page #
#######################################

if( $page == "about" ){

include "site/temp.php";
}

#####################################
# Contact us Page #
#####################################

if( $page == "contact" ){

include "site/temp.php";
}

######################################
# Members Page #
######################################

// Note* you may want the user to login before hand, if you do so I would recommend using sessions, instead of cookies. for the purpose of this tutorial.

if( $page == "members" ){

include "site/temp.php";
}

// Note you can always make more members pages but to speed up things im just going to show you how to make them really fast

/*

if( $page == "members" and $act == "thepage" ){

include "site/temp.php";

}

*/

// Note* the $act == "thepage" is the page that you wish for them to request.. I have blocked commented it out....
####################################################
# Now this is when the user logs out only works with sessions. #
####################################################

if( $page == "members" and $act == "logout" ){

session_destroy();
header("Location: index.php");

}

?>



Now, you are probally thinking why doesn't he just make it all in one if? well, i tried it and got an error when i was designing my Exchange program.
especially when a user logged out, it would get an error. error would say HEADERS have already been sent.


So, whats next lets see now we need to make... a page that is going to show what needs to be shown... You need to add the content your self I am going to be using dummy text as an example.

So, lets create another file called show.php we need to save this in a new folder, so create a new folder called plugins
and then save it.

We need to add the following into the show.php file

Now this part may confuse you but I will explain it at the end.


You also need to create a couple more files,

for your index page create

a new folder inside of plugins and call it site and
so it would be like plugins > site

now create and save a file in this folder called home.php this will be your HOME PAGE!
so it should look like

plugins/site/home.php


now in the site folder still create a file called contact and about both with .php exts ok.

Ok, now we need to just go ahead and create the members page, remember i said you can just create all the pages you want, but i wasnt going to, it would take to long but i did show you how rember that... now for the members page go to the plugins folder and create a folder called members

and in that folder create a file called home.php
so it should look like plugins/members/home.php

In those files just go ahead and add your forms our what ever... adding dummy text would just make this tutorial way to long, so go ahead and add the content to all the files giving to create, or however you want to do it.

CODE


<?php

if( $page == "home" or $page == "main" or $page <= " " ){

include "plugins/site/home.php";

}

if( $page == "contact" ){

include "plugins/site/contact.php";
}

if( $page == "about" ){
include "plugins/site/about.php";
}

if( $page == "members" ){
include "plugins/members/home.php";
}

?>



That should do it for that file, now remember the temp.php file? make sure it is blank, and place the following code where you wish for the content to show up at

CODE

<?php include "plugins/show.php"; ?>


Now how does the navagation work? well, just remember what you created and how you wish to make it look in the url...

ex home page would be index.php?do=home
or about us index.php?do=about
or member logout index.php?do=members&act=logout

It's just so easy once you understand it. try it you will see and if you dont understand just PM me... also u can take a quick look at a example that is limited in functions, but shows u what it can do at

http://exchange.aogpro.com it is just to show you what it can do and most features are disabled, some dont even work at ALL!

 

 

 


Comment/Reply (w/o sign-up)

saulg
i'M Gonna have to try to do this... i'm not shure if we should do this, maybe could yuou tell me why this method is better than others. I really dont think this is better, cuz if you use POST then your users cant save links, or exchange them...

Comment/Reply (w/o sign-up)

flopadmi
QUOTE(saulg @ Jul 5 2007, 08:30 AM) *
i'M Gonna have to try to do this... i'm not shure if we should do this, maybe could yuou tell me why this method is better than others. I really dont think this is better, cuz if you use POST then your users cant save links, or exchange them...

yah man nice to see u
thanks

Comment/Reply (w/o sign-up)



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : making, page, website, phph

  1. Creating Common Navigation For A Website: Part 2
    Newbies guide to creating common navigation with PHP (0)
  2. Rfi (remote File Inclusion) What Is It? How Do I Stop It?
    Another website security tutorial (0)
    In my continuing attempts to learn more about website security i am going to tell you about a
    classic attack called Remote File inclusion (RFI). RFI is exactly what it says really, it involves
    using (or including) code from one website on another website. So if i have a website : secure.com
    with a modular, dynamic system like: secure.com/index.php?module=home notice the GET variable on
    the end of the URL. If i enter "blah" instead of "home" i get either a blank page, or a 404: page
    not found error, there is also a chance you will get an error message like: Error: inclu....
  3. My First Website
    Where can i find useful web page templates? (14)
    Hi folks, Just wondering, as a newbie website builder, where can I get some useful HTML, CSS
    templates suitable for building a small business website? What is the best development environment
    for building websites? Is there a good open source program available?, or is it best to spend some
    money on something like Dreamweaver? Does anyone have experience of adding databases to Trap17
    sites, perhaps using Wamp server?....
  4. Making Calculators with PHP
    Some basic calculator scripts I made. (4)
    Yes, I made some basic calculators to use for simple math problems, nothing big. I'm a newbie at
    php, so if I made something that could be short, long, I am sorry. lol Here is one for adding two
    numbers. CODE Adding 2 numbers Type in the two numbers you'd like to add together.
    + Save that and name it add.php or add.html, it don't matter. In that
    page, it is simply asking for 2 numbers to add. Next, create a page called add2.php, can't make
    it html. CODE $_POST ; $_POST ; ?> Answer to + Answer to + ....
  5. How To Make An Ultimate Game List.
    If you're making a site on video games or such. (0)
    Hello. I am BuBBaG. You can call me Bubba for short. I'm going to show you how to make an
    Ultimate Game List. First off, we need to make a database, we are going to call this database
    `my_db`, leave out the `'s. Inside that database we will need to create a table called
    `ugl'(Ultimate Game List, duh). To make the table, simply enter this in the Syntax. CODE
    CREATE TABLE ugl ( System char(50), Game char(50), ) In the above code, it is stating we are
    creating a table called ugl, with two columns, System, and Game. Next, we will need to make a form,
    t....
  6. Ftp In Visual Basic 6.0
    Start making your FTP client using VB6 (3)
    Recently, I had a need to make a FTP client, since our webhosting FTP server was kind of exotic, and
    very restrictive, and most of uploads, even though they reach 100% would crash... File would be
    uploaded to a server, but FTP clients just froze upon completion, waiting for the 226 (OK) from FTP
    server... So, I had to make my own, one who would not wait for 226, but instead, watch the file
    pload progress... This tutorial is not fuly complete, in the sense that it does not offer COMPLETE
    FTP client functionality (for example, I ddn't write the code for FTP download, ....
  7. How To Setup A Website After Your Forum
    (3)
    This tutorial is about how to setup a website after you have setup a forum. That means, you have a
    forum, and are wanting to add a website. This tutorial will show you how to create the website in
    your root directory(Example: http://domainname.com) , while your traffic gets redirected to your
    forum while you are creating it, until you're ready for guests to see it. This method is
    opposed to setting it up in another directory, then moving it(particularly more time consuming if
    you're site is PHP based). First of all, you are going to want to setup a redirect ....
  8. Making A Song In Fruity Loops Part Three
    part three precusion (1)
    ok part three now which covers the precusions setup of the small song i built for this tutorial.
    the nesecery files can be downloaded here the image below is included in the precusions folder as
    it mught not be entierly visable within this post so shold you need it its there also the images
    purpose is to enable you to see what i am refering to within this tutorial lateron. now what i
    have done above is blackd out every pattern that has nothing to do with the precusion. so the
    patterns displayed in light grey are the only patterns i will be refering to. ok lets b....
  9. Making A Song In Fruity Loops Part 2
    part 2 the second melody (0)
    ok i am going to attach the midi file againe incase you didnt get it from the first part in this
    part i will demonstright how to create and insert the second mellody ok so you have your first
    mellody wich is ecetially the comein chord as i call it. now open the midi file you put in your left
    panel during the first tutorial and drag the mellody 2 © onto the pallet but click on pattern two
    in the right site playlist box. now like in the first tutorial replace with sytrus. for this type
    of mellody use something in the leads section of the plugin.for this you need to ....
  10. Creating Navigation For Html Websites
    Have a common navigation menu for the whole website! (12)
    Pre-requisite: HTML, inline frame tags 1 Attachment(.zip) included. Updates : 29-12-07: Doctype
    added in example files (Advised by jlhaslip) Designing a whole website takes a lot of planning
    and organization. Designing a proper navigation system is a basic step in building your website. If
    you are developing webpages in html you would have observed that as you go on creating pages it
    becomes difficult to maintain the links to the pages. This article will guide you in developing a
    common navigation menu for your website. It describes three ways, so if you don'....
  11. Css Scroll Bar Styles
    Change the color of your website scrollbar! (1)
    REQUIREMENTS 1. Must have limited to good knowledge of CSS. 2. Must have limited to good knowlege
    of HTML. THE ELEMENTS First of all, there are 7 different elements of a scrollbar. a) Scrollbar
    Arrow Color /cool.gif" style="vertical-align:middle" emoid="B)" border="0" alt="cool.gif" />
    Scrollbar Darkshadow Color c) Scrollbar Track Color d) Scrollbar Face Color e) Scrollbar Shadow
    Color f) Scrollbar Highlight Color g) Scrollbar 3dlight Color Bassically all that you need to do is
    change the colors like you normally do with any sort of CSS. Therefore, if you want the....
  12. Creating A Resume
    10 Tips For Making A Resume (1)
    I've been working on my Resume for months now. Here is a summary of what I've learned: 1.
    Avoid referring to yourself via 1st person or 3rd person terms. Rather than saying "I started this
    job in" just say "Began job in"... Employers expect Resumes to be professional and avoid reference
    to oneself; and instead speaking in an impersonal tone that presents
    achievements/skills/experience/education without personalization. Avoid words like "I", "my", "he",
    "she", etc. Leave out personal pronouns and only use the action words/verbs. This also includes
    your Ob....
  13. Adding Your Website To Google
    How to register with google (25)
    Hi everyone. Hopefully here im going to tell you how to register yourself with the Google search
    engine and get yourself in their results. Ill start the tutorial assuming you already have Meta
    tags or other search engine optimisation techniques in place. This tutorial is solely about
    registering with google. At one time i thought simply using meta tags etcetera would get you listed
    in Google, i then found out that didnt work, so i wondered why, and the fruits of my labour are what
    will go into this tutorial. the first step is to get a google account, this will get y....
  14. Making a java based program
    (3)
    Java GUI Making a Little Java Program Sec. 1: Imports and starting it off Sec. 2: Variables Sec.
    3: Frame and Stuff Sec. 4: Declaring buttons Sec. 5: Adding buttons Sec. 6: Action Listening Sec. 7:
    Using this for a learning experience Section 1 Now, let's think. What imports do we need? We
    obviously need GUI imports. We also need the action Listener. So, let's declare this at the very
    top: Code: CODE import java.awt.*; import java.awt.event.*; import javax.swing.*; That's
    all we need to get all our supplies. Now to start us off. Skip a couple lines ....
  15. Making The Popular Id Browsing For Your Site.
    (17)
    Was just sitting and being bored but then I realized I could show how to create more or less popular
    ?id=page browsing. It's actually really easy. I know two ways how to do it. First one I learned
    was checking the variable and if it's true including the text/file/anything needed and so on. It
    was ok, but sometimes I just couldn't make it work so I switched to switch() function and
    that's what I'm going to show you guys right now. So, I made a test page which contains the
    code needed and here is its source. CODE Untitled Home - P....
  16. Making A Dynamic Page On Blogspot
    Using an external server to make your pages hosted on blogspot dynamic (5)
    Good morning everyone. Have you ever wondered how to allow your visitors to edit content on your
    blog? Like adding a post straight off the page, adding a link, editing your profile etc. This will
    be extremely useful if you want your visitors to contribute to your blog besides writing comments or
    tagging. 1. Adding a post straight off the page. Go to blogger.com, login, select your blog. Go to
    settings -> email. By enabling blog email, you can now add a post by simply sending an email to the
    address you specified. The address should look something like: yourusername....
  17. Making Interactive Cds With Flash
    My second flash tutorial for Beginners (2)
    Im back again with what i think it would be an interesting tutorial for all of you guys who wants to
    take flash out of the web and make really cool interactive CDS. First of all if all of you are
    thinking right now: "this dude is wrong for making interactive cds you have to use macromedia
    Director", well you are right macromedia director it's used to build interactive cds and dvds
    among other things, but you can also make interactive cds with Flash, the thing is: if you want to
    make a simple interactive CD you can totally do it with flash, of course Director brings ....
  18. How To: Make A Simple Php Site
    Making one file show up on all pages using php (21)
    I have looked all over the site and could not find anything that was like this simple, or just like
    this at all.. For some people i know that you are using a basic HTML site...and having a big menu
    if you want to add somthing you have to go into every one of the pages and add or remove or edit
    what you want to do, but with somthing verry simple all you would have to do is edit one file, and
    all of the pages that have the PHP script on them would suddenly change to what that one file is.
    So to start off if you are planning on using this little tirck, the page that you a....
  19. Checking Dns Settings For Website
    DNS Setting, Ping, Whois, Dnsreport etc (2)
    If you have recently purchased a domain and facing problems with the workings, the first thing which
    you should check is the DNS setting. Dns settings determine, how to domain is pointed to the Server
    and How the server is connected to the world (internet). Ensure, the DNS settings are perfect to
    make sure, things work smoothly and people across the globe don't have problems accessing your
    site. The basic check would be : PING Suppose you register your domain (example.com) at
    ComputingHost. You get an IP for your website. In this case, suppose its 64.69.35.170. Yo....
  20. Configuring Dns Settings For Website
    Nameserver, A-Address, DNS configuration (1)
    Most of the people have problems configuring their website. After registering their domain, many get
    confused in configuring their domain (basically the DNS settings). This small tutorial will help you
    get started with DNS settings configuration. A domain can be basically pointed to a server using 2
    main techniques. 1. Nameserver (the most recommended way) 2. A Address (Not recommended)
    Configuring using Nameservers ==================== Login to your domain Control panel provided by
    your DOMAIN NAME PROVIDER / REGISTRAR. Not your webhost. Search for settings like DN....
  21. Introduction To Templating
    Templating your website with PHP (1)
    Pre-note Hello and welcome. if your website doesn't use a templating function, you may have
    noticed it's pretty hard to update your website (layout) unless you dig through many files to
    update the images and such. The solution is templates. If you ever got curious and looked into
    phpBB codes or any other template based forum/CMS, you saw the .tpl files they use. I am not at a
    point where i base everything on .tpl (simply because i havent taken the time to see how it all
    works). But i do can tell you that it's the same principle, template your site using an....
  22. Making Winrar Archives
    and adding password to winrar archives (15)
    **** This tutorial will show you how to put files into .rar Archive and pass worded (if wanted)
    **** What You Will Need Before continuing you will need a couple of thing, first of all you
    need WINRAR , which is a very powerful archive manager. It can reduce size for you email
    attachments, decompress RAR, ZIP and other types of files downloaded from the internet. You can get
    winrar at http://www.rarlabs.com The other thing is that make sure your using Windows XP because
    this is what I used to make this tutorial. I think it works with any other windows not....
  23. Tutorial: Installing D-shoutbox For Ipb V1.2
    Making your installation even easier (12)
    Over the course of the summer I have tried hard to install a shoutbox into a new forum I was
    developing. I went to the Invisionalize forums and found several mods for shoutboxes, but none of
    them seemed to work. I first tried to install the D-Shoutbox, but upon this first try, I was
    unsuccessful. Eventually, after much frustration, and trying other mods, which didn't seem to
    stack up to Dean's features, I was determined to make it work. For some, editing your files (to
    the newbie that is) can be difficult, with everything looking like a foreign language (basi....
  24. Making Shadows Without Images
    (4)
    Im going to show you very simply how to create boxes with Shadows using div tags and css, no images
    needed, meaning fat pageload times! /biggrin.gif' border='0' style='vertical-align:middle'
    alt='biggrin.gif' /> You simple need to create two layers, one behind the other, the one behind
    will have a top and left margin on 20px, the one infront 10px, set teh background colour of the one
    behing darker than teh one infront, you should end up with something like this: Here is th html
    to create this effect: CODE Its as simple as that, two divtags, a bit of cs....
  25. Centered Website With Two Columns
    CSS (12)
    This is upgrade of my first tutorial for Centered website with fixed width. Today I am going to
    present you tutorial for making two columns website with fixed width. My basic tutorial can be found
    here: here. So let's begin: First we will change CSS file, everything stays same if not
    mentioned to change, starting with color of content from basic tutorial, change background to this
    code. This will actually be background of left column and padding will be set to 0, cause it will be
    defined in Left and Right column. New code for Content: CODE #Content{  width:....
  26. Centered Website With Fixed Width
    ...begginers lesson... (2)
    This will be tutorial on how to make a simple website design with fixed width and center position.
    This is actually rather simple tutorial, but hopefully it will help others that are new in world of
    creating websites. Website will also contain header, content area and footer. First we must do
    Wrapper. Wrapper is actually an area of fixed width and will be position into center, so that our
    page doesn't fall apart. CODE body{ width:100%;  margin:0px;  padding: 0px;
     text-align:center; background:#FFFFFF; } This is actually an IE5 hack were we did c....
  27. Making A Webserver Directory Listing
    Helps you organise your webserver (6)
    I recentely installed IIS with PHP and MySQL on my pc (previous I used UniServer, but that
    doesn't matter here). But I had always to go to http://localhost/websiteiwanted or I had to
    create a shortcut on my desktop for every site so I decided to create an "overviewpage". It shows
    all the websites in your wwwroot with a link to them. If you have folders you don't want to be
    included, you extense the && check (but I'll explain this lateron) Here's the total code:
    CODE $dir=opendir('.'); $isdirtrue = false; while ($file = readdir($dir)){ ....
  28. Secure The Email Addresses On Your Website!
    Wonderful script and useful! And working (10)
    Just follow the instructions below: /* Secure Email Function by Juan Karlo Aquino de
    Guzman Website: http://www.karlo.ph.tc and http://www.abs-cbn.ph.tc E-mail:
    http://www.karlo.ph.tc/send.php Usage: showEmail("support@microsoft.com",0); OR
    showEmail("support@microsoft.com",1); Types: 0 = ordinary random 1 = more secure random To
    include to a script: include_once("email_secure.php"); */ And here is the code :
    CODE /*     Secure Email Function by Juan Karlo Aquino de Guzman     Website:
    http://www.karlo.ph.tc and http://....
  29. E-mail Mailer Script 0.1
    useful for website visitors (4)
    Are you pissed off when you are putting e-mail in your website, you always get spammers? Well,
    here's the solution. Just change the default variables to anything that you like, etc... follow
    the instructions on the script.. Here it is... hope you like it /smile.gif' border='0'
    style='vertical-align:middle' alt='smile.gif' /> CODE //E-mail Mailer Script 0.1 by Juan
    Karlo de Guzman //FOR TRAP17 ONLY... DEMO VERSION... DO NOT DISTRIBUTE header("Content-type:
    text/html; CHARSET=UTF-8"); $int_rand=mt_rand(1,20); if($int_rand>10) {
    $random_numbers=sha1(mt_ra....
  30. Making A Website
    Also Some Dos and Don'ts (6)
    I had originally had this posted on my domain at nevernormal.com, and thought that you guys could
    use it here as well. Granted, this is geared to the uber newbie, so don't razz me if I
    don't suggest the most advanced in web design. lol So, you want to make a website? 1.
    First, think about what you want your site to be about. There are fanfic sites, like Drastic
    Measures and fanfiction.net ; cliques or clubs, like the BtVS Writers' Guild ; or, if you
    want, you could have a general site, whether it be about a show/movie you like, or even just about y....

    1. Looking for making, page, website, phph
Similar
Creating Common Navigation For A Website: Part 2 - Newbies guide to creating common navigation with PHP
Rfi (remote File Inclusion) What Is It? How Do I Stop It? - Another website security tutorial
My First Website - Where can i find useful web page templates?
Making Calculators with PHP - Some basic calculator scripts I made.
How To Make An Ultimate Game List. - If you're making a site on video games or such.
Ftp In Visual Basic 6.0 - Start making your FTP client using VB6
How To Setup A Website After Your Forum
Making A Song In Fruity Loops Part Three - part three precusion
Making A Song In Fruity Loops Part 2 - part 2 the second melody
Creating Navigation For Html Websites - Have a common navigation menu for the whole website!
Css Scroll Bar Styles - Change the color of your website scrollbar!
Creating A Resume - 10 Tips For Making A Resume
Adding Your Website To Google - How to register with google
Making a java based program
Making The Popular Id Browsing For Your Site.
Making A Dynamic Page On Blogspot - Using an external server to make your pages hosted on blogspot dynamic
Making Interactive Cds With Flash - My second flash tutorial for Beginners
How To: Make A Simple Php Site - Making one file show up on all pages using php
Checking Dns Settings For Website - DNS Setting, Ping, Whois, Dnsreport etc
Configuring Dns Settings For Website - Nameserver, A-Address, DNS configuration
Introduction To Templating - Templating your website with PHP
Making Winrar Archives - and adding password to winrar archives
Tutorial: Installing D-shoutbox For Ipb V1.2 - Making your installation even easier
Making Shadows Without Images
Centered Website With Two Columns - CSS
Centered Website With Fixed Width - ...begginers lesson...
Making A Webserver Directory Listing - Helps you organise your webserver
Secure The Email Addresses On Your Website! - Wonderful script and useful! And working
E-mail Mailer Script 0.1 - useful for website visitors
Making A Website - Also Some Dos and Don'ts

Searching Video's for making, page, website, phph
See Also,
advertisement


Making A One Page Does All Website In Phph

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com