1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Include command to load seaparate parts of my website...

Discussion in 'PHP' started by elan.miller, Sep 6, 2005.

  1. #1
    I'm building a website - www.ucljsoc.com, please take a look...
    the problem is that the homepage doesn't appear, but the area around it does.

    I have used the include command so that the top, bottom and the left sides of the page remain constant. This saves bandwidth and loading times.

    Unfortunately my knowledge of PHP is somewhat limited, and my google searches have been renedered fruitless! Therefore I turn to you...

    I want the page http://www.ucljsoc.com/index.php?page=home to load automatically when www.ucljsoc.com is typed in.

    Have a look at my PHP:
    ------------------------------------------------------------------------


    $p = $_GET['page'];
    $pages = array("home","register", "sign_in", "events", "photogallery", "about", "contact_us", "campaigns", "education", "fundraising", "welfare", "sponsorship", "competitions", "freshers", "commitee", "hillel_news", "halls", "timetable", "shabbat", "fun_and_games");
    if (in_array ($p,$pages)) {
    if (!$p) {
    $p = "home";
    }
    include "$p.php";

    } else {
    echo "<font color = 'White' size=2>The www.ucljsoc.com server cannot find your page. <BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>Instead of an impersonal generated message, I will leave a more personalised generated message here:<BR><BR><BR><BR>You either mis-typed the address, or the page that you want no longer exists.<BR>Either way, get in touch with us, and we'll do our best to rectify the problem.</font>";
    }

    ----------------------------------------------------------------------
     
    elan.miller, Sep 6, 2005 IP
  2. Connect

    Connect Guest

    Messages:
    191
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try this:

    
    $p = $_GET['page'];
    $pages = array("home","register", "sign_in", "events", "photogallery", "about", "contact_us", "campaigns", "education", "fundraising", "welfare", "sponsorship", "competitions", "freshers", "commitee", "hillel_news", "halls", "timetable", "shabbat", "fun_and_games");
    
    if (!$p) {
    	$p = "home";
    }
    
    if (in_array ($p,$pages)) {
    	include "$p.php";
    } else {
    	echo "<font color = 'White' size=2>The www.ucljsoc.com server cannot find your page. <BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>Instead of an impersonal generated message, I will leave a more personalised generated message here:<BR><BR><BR><BR>You either mis-typed the address, or the page that you want no longer exists.<BR>Either way, get in touch with us, and we'll do our best to rectify the problem.</font>";
    }
    
    PHP:
     
    Connect, Sep 6, 2005 IP
  3. rehash

    rehash Well-Known Member

    Messages:
    1,502
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    150
    #3
    include executes on the serverside so you dont save anything but server space :D
     
    rehash, Sep 22, 2005 IP
  4. DavidAusman

    DavidAusman Peon

    Messages:
    399
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #4
    connect's script should work fine i guess
     
    DavidAusman, Sep 22, 2005 IP
  5. LAMP

    LAMP Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I would do it this way.. no need to have a page array

    $page = isset($_GET['page'])? $_GET['page'].'.php' : 'home.php';
    if ( file_exists($page) )
    include $page;
    else
    echo "no Page";
     
    LAMP, Sep 23, 2005 IP