Trying to Create an Audit Trail For Log in User History [duplicate]

I just started creating a website at my home.

Absolutely, I must have these two pages to finish my website rapidly:- footer.php, header.php.

So I created those pages & put some contents. Also created an index page as index.php inside the htdocs folder.

Then I did include the header & footer pages inside the index.php page by using these following codes.

<?php include 'header.php'; ?>
<?php include 'footer.php'; ?>

Undoubtedly, they worked fine without any trouble.

Then I created a directory as account inside the htdocs.

Now I've a login.php page inside the account directory (/account/login.php).

Repeatedly I used those same codes to include the header & footer in the login page. But they didn't work! I saw nothing is happening. If I create the login.php page inside of the htdocs folder (not in htdocs/account/), so it works.

So, how can I include them while the login page is in account directory?


Solution 1:

When creating sub directories and including files it is always simpler to use absolute file paths.

The path with reference to root directory is called absolute (https://www.website.com/modules/header.php), you can even remove the domain and just have /modules/header.php. The path with reference to current directory is called relative (../images/phone.png). The ../ indicates that the URL points to the directory above the current folder.

Please see answers relating to a similar question here: difference-between-relative-path-and-absolute-path-in-javascript