Current location: Hot Scripts Forums » Programming Languages » PHP » Site using includes


Site using includes

Reply
  #1 (permalink)  
Old 07-01-04, 05:43 PM
Bonzo's Avatar
Bonzo Bonzo is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 340
Thanks: 0
Thanked 0 Times in 0 Posts
Site using includes

My site is basicaly a header - navigation; content - included pages & a footer. The page to include is passed in the URL.

The code I write is simple and works OK with this method

I have tried to include forums, login pages etc. and none of them work.

I have to change the paths e.g. index.php ( my template ) -> including main.php ( forum main page ) -> including config.php

Normaly the path to config.php for the forum would be config.php but as I am including main.php into index.php the path becomes forum/config.php !!

That is the first problem that can be overcome by changing the paths in the code.

The next problem is the worst; Say a login page -> enter details -> submit -> allowed in or error. But for me this will not work - nothing happens even if I input the wrong details. But the code works OK as a stand alone script.

Anyone have an idea how I can get over this ?

Anthony

Works OK - http://www.rubble.info/TESTS/main.php
The password should be password

Will not work - http://www.rubble.info?inc=test
Reply With Quote
  #2 (permalink)  
Old 07-01-04, 07:45 PM
infinitylimit's Avatar
infinitylimit infinitylimit is offline
Code Guru
 
Join Date: Jun 2004
Location: Oregon
Posts: 758
Thanks: 0
Thanked 0 Times in 0 Posts
I've had this problem before, post a snippet and I could tell you what is going on.
__________________
Hawk Enterprises -- Home to PHP games, open-source code, tutorials and free downloads
Reply With Quote
  #3 (permalink)  
Old 07-02-04, 01:11 AM
Bonzo's Avatar
Bonzo Bonzo is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 340
Thanks: 0
Thanked 0 Times in 0 Posts
Its very anoying as I like this method of building a site.

Hope the bit below helps if not I will post more when I am back from work.

Anthony

PHP Code:



// the main.php I am including

require("photo/uplConfig.php");
include(
"photo/functions.php");

// start of upload script
if (!isset($_POST["upload"])) { // case upload button was not pressed yet
    
showForm();
} else { 
// upload button was pressed; process upload
    
upload($_FILES);
// end else


// one of the functions

//destination= full path to the uploaded file
$destination $baseFolder $_FILES['file2upl']['name'];

//************************************//
//  CHECKING IF USER SELECTED A FILE  //
//************************************//
    
if (!empty($_FILES["file2upl"]["name"])) {
        echo 
" " $_FILES["file2upl"]["name"] . ":<br>\n";
    }
        else echo 
"Please, select a file to upload<br>\n";

    if ( (isset(
$_POST["pwd"]) && $_POST["pwd"] == "$passwordUpl") || $passwordUpl == "") { // password is ok

// creating upload-folder if does not exist yet        
        
$test = @opendir($baseFolder);
        if (empty(
$test)) { 
            
mkdir ($baseFolder0755);
        }
//chechikg if, for some reason file wasn't uploaded        
        
if ($_FILES['file2upl']['tmp_name'] == "none") {
            echo 
$errMsgNoup;
            
$ok "no";
//checking filesize
        
} elseif ($_FILES['file2upl']['size'] > $maxSize) {
            echo (
"File you tried to upload is: ".$_FILES['file2upl']['size']."Bytes<br>");
            echo 
$errMsgToobig;
            
$ok "no";
        } else { 
// file size is ok 
Reply With Quote
  #4 (permalink)  
Old 07-02-04, 02:17 PM
infinitylimit's Avatar
infinitylimit infinitylimit is offline
Code Guru
 
Join Date: Jun 2004
Location: Oregon
Posts: 758
Thanks: 0
Thanked 0 Times in 0 Posts
okay with all your include paths add ./ to the front of them. This will tell the server to start from the current directory and go on from there. I think that might fix the problem.
__________________
Hawk Enterprises -- Home to PHP games, open-source code, tutorials and free downloads
Reply With Quote
  #5 (permalink)  
Old 07-02-04, 02:21 PM
Bonzo's Avatar
Bonzo Bonzo is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 340
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks for that infinitylimit, I will give that a go later.

I was thinking is there a better way of going about this ? Should I have say the content part as the page with the template header etc. included into it instead ?

Anthony
Reply With Quote
  #6 (permalink)  
Old 07-02-04, 02:34 PM
Bonzo's Avatar
Bonzo Bonzo is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 340
Thanks: 0
Thanked 0 Times in 0 Posts
I am afraid that your last sugestion infinitylimit worked OK with the includes etc. but did not help with the scripts.

But I am thinking about my last post - a bit of laterial thinking with you making me think. If I go for a layout where the script is the main part and the header & footer are included into it instead; then the scripts should work OK ?


Anthony
Reply With Quote
  #7 (permalink)  
Old 07-02-04, 02:54 PM
Bonzo's Avatar
Bonzo Bonzo is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 340
Thanks: 0
Thanked 0 Times in 0 Posts
I think this must be the way to go but it would be better to start from scratch OH NO !

Anyway having a break now but one question for you all while I am away :

How do I get this line to load the new page ?

PHP Code:

// Was

elseif ( $inc == 'test' ) { include "test.php";}

//Now I need something like this ?
elseif ( $inc == 'test' ) { echo '<a href = "test.php">';} 
Anthony
Reply With Quote
  #8 (permalink)  
Old 07-02-04, 03:37 PM
Bonzo's Avatar
Bonzo Bonzo is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 340
Thanks: 0
Thanked 0 Times in 0 Posts
To much upheaval - leave as it is for now and try writting my own code. Have another look at this when I get time.

Anthony
Reply With Quote
  #9 (permalink)  
Old 07-03-04, 09:51 AM
Bonzo's Avatar
Bonzo Bonzo is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 340
Thanks: 0
Thanked 0 Times in 0 Posts
I am having a go at redoing the site now - such a lot to sort !!

The including the header/ navigation into the page is working but means a lot more work on each page unless I can find an easyerway.

This has now screwed up my navigation buttons and my pages try to load in the current folder not the folder they should - the old memory is going and I am trying to figure this out again.

Anyway I thought I would let you know how things are progressing.

Anthony

I think if I topup the alcohol level things might improve
Reply With Quote
  #10 (permalink)  
Old 07-03-04, 03:45 PM
Bonzo's Avatar
Bonzo Bonzo is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 340
Thanks: 0
Thanked 0 Times in 0 Posts
All seems to be working now http://www.rubble.info/TESTS/site/photo/main.php
just some css to sort then its back deciding what I want to put there !!

The main page now is the content and the navigation is included.

Anthony
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Accepting bids for hosting site re-design and ModernBill setup/integration SN-Coach Job Offers & Assistance 9 04-28-04 08:52 AM
Making the site of ur life ~SaraAnders~ The Lounge 10 04-18-04 11:04 AM
I developed a site .... Adi New Members & Introductions 3 08-23-03 11:02 AM
Does anyone know what type of script this site uses The Probuilder Script Requests 3 08-22-03 02:03 PM


All times are GMT -5. The time now is 05:08 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.