Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New Coder
    Join Date
    Apr 2009
    Posts
    59
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Good way to use subfolders?

    I'm creating mysite.com and all works fine. Now I'm making admin stuff so its mysite.com/admin/ and having errors with the sessions working on pages within /admin and also links I have to define as ../linkname.php/html can anyone give me a pointer as to whats up plsss?

  • #2
    New Coder
    Join Date
    May 2009
    Posts
    55
    Thanks
    1
    Thanked 4 Times in 4 Posts
    What you say is not that clear and i cannot really help. Could you explain a bit better what the problem is? From what i hear i suppose that it may be a urls rewrite problem probably.

  • #3
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    I guess you are asking about making your links work when the file using them is inside a different directory/folder, from the ones which do work.

    Well, while I do not understand the link ../linkname.php/html I think you may benefit from the following:

    Links should be locally global IMV. That means they are going to work no matter the site structure and they are not relative to the url/domain.

    so I usually use /folder/filename.php/params. The is a link that goes from the root directory

    folder/filename.php/params takes you to the sub-folder of the folder containing the file.

    for your sessions issue, you'll need to post the code so we can see why it works in the root dirs but not in the admin dir.

    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #4
    New Coder
    Join Date
    Apr 2009
    Posts
    59
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Hey bazz. General code I'm using for starting pages is as follows:

    PHP Code:
    <?PHP session_start(); 
    ini_set("session.gc_maxlifetime""180000"); 
    ?>
    Then underneath that I type my code. So basically if you think about file structure I want the main site to be mysite.com/ and whatever pages there. Then, I want a mysite.com/admin so that way all my admin pages and stuff I code can be in mysite.com/admin/.....php

    So overall I have a simple mysql database. In the database it has a users table with an admin field set to value of y or n defaulted to n.

    When user logs in if they have the admin y then the header has an include code to include a header with admin links. Then admins can click around those links, and do different admin stuff. Here is code to include admin links from my header.php.

    PHP Code:
    <?



    include("db.inc.php"); 
    $id_user=$_SESSION['id_user'];

    $check=mysql_query("select * from users  where id_user='$id_user'");
    $result =mysql_fetch_array($check);
    $admin=$result['admin'];

    if (
    $admin=='y')
        {
            Echo 
    "<TABLE border=40 cellspacing=0 cellpadding=0 width=100% bgcolor=#E6F3FF>
    <tr>
              <td align=middle class=navText>USER ID: " 
    $id_user "<BR><A href=/messageoftheday.php>Message of The Day</A> Reserved for future use</td>
            </tr>
        </TABLE>"
    ;
        }
    ?>

  • #5
    New Coder
    Join Date
    Apr 2009
    Posts
    59
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Oh let me state how site is laid out basically. . .


    I have a header which displays my banner, and possibly admin links. I do an include statement on every page to include the header.

    Then I have the main body of the page usually setup as such:

    Code:
    <HTML>
    <TABLE>
    <TR>
    <TD>
            <TABLE>
            <TR>
            <TD>Include loggedinlinks.html here</TD>
            </TR>
            </TABLE>
    </TD>
    <TD>
            <TABLE>
            <TR>
            <TD>Main stuff for current page your on goes here</TD>
            </TR>
            </TABLE>
    </TD>
    </TR>
    </TABLE>
    </HTML>


    Pardon me if my coding convention sucks, I'm no pro, just doing this for fun, and learning.

  • #6
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    OK, I was trying to help with the links issue you were having. I am unable to assist with your sessions trouble because I have never used them in php.

    as for your coding convention...yup, it seems wrong because you are using tables for layout. You said you were doing this for fun and learning so it would be better to start with semantic code now rather than learning two different ways, when the first is wrong and therefore a waste of your time.

    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #7
    New Coder
    Join Date
    Apr 2009
    Posts
    59
    Thanks
    3
    Thanked 0 Times in 0 Posts
    bazz, if I shouldn't be using tables for my layout, what should I be using? Templates? Templates are done in CSS, which end up as tables anyways, right?

  • #8
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    Quote Originally Posted by doodguy View Post
    bazz, if I shouldn't be using tables for my layout, what should I be using? Templates? Templates are done in CSS, which end up as tables anyways, right?
    Use divisions. Tables are good for tabular data - such as database output - if the data is easier to read or input with the tab key.






    --------
    Leonard Whistler

  • #9
    New Coder
    Join Date
    Apr 2009
    Posts
    59
    Thanks
    3
    Thanked 0 Times in 0 Posts
    cool. I'll look into divisions.

    In the meantime, how do I enable sessions to work back and forth between /admin and root folder? Is it possible?

  • #10
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    Quote Originally Posted by doodguy View Post
    cool. I'll look into divisions.

    In the meantime, how do I enable sessions to work back and forth between /admin and root folder? Is it possible?
    Yes ..... Also to link between folders use ../ Example:

    home/admin
    home/includes

    The db_connect.php is in the includes folder, but you also would like to use it from within the admin folder. The link would be:

    "../includes/db_connect.php"


    --
    Last edited by Len Whistler; 05-12-2009 at 10:09 PM.
    Leonard Whistler


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •