My Header navigation menu links are malfunctioning...
My project folder has 2-3 sub-folders. One of them is the "INCS" folder, which carry some files like the "HEADER.php","FOOTER.php" e.t.c. Another sub-folder "USER": Which is the folder that contains every file that that does processes on the user. For example the "USER" folder has the "WELCOME.php", "INDEX.php" files in it, which is where the user is redirected to after successful Login.
In the "WELCOME.php" file for example i included the "HEADER.php" file from the "INCS" sub-folder in this manner "../incs/header.php".
<div class="probootstrap-loader"></div>
<?php include '../incs/header.php'; ?>
<!-- END: header -->
I expect that on the "WELCOME.php" page, when the user clicks on the "NAVIGATION LINKS" it should be like this structure "root/link.php" and that it should take the user to the "LINK" page, but when i hover on any of the links i get this structure "root/user/link.php".
Considering the fact that these other links are in the ROOT DIRECTORY not the SUB-FOLDERS..
I really hope someone understands this, because its the first time i am experiencing this issue and i don't know how best to explain it
Related
The problem is as follows:
Originally, all of the individual pages on my website were in the root folder of the site.
I have now moved the majority of the pages into various sub-folders.
For example: The main page for our Apache Totem Freestanding Light Box used to be in the root folder, but is now in subfolders: /lightboxes/apache-totem-freestanding-lightbox/index.php
The problem is that various elements of the page have “PHP Modules” included for common elements such as the header, the breadcrumbs, the footer, the css file etc.
For example, for the header we have as a link on each page.
The files that these “PHP includes” point to are situated in their own folder on the site root, called ‘modules’.
The trouble with this, is that the ‘PHP Includes’ can’t seem to find the modules because I guess they are expecting to see them in a folder called ‘modules’ that is situated in the same subfolder as the current page.
I’ve partially got around this by changing the link to the module to have ../../ in front to tell it that it has to look two folders up from the current folder, but the page is still having difficulties displaying all of the information.
To give you an idea of this, I have uploaded the Apache Totem Index Page in its subfolder /lightboxes/apache-totem-freestanding-lightbox/
https://www.w-co.co.uk/lightboxes/apache-totem-freestanding-lightbox/
As you can see, the main content of the page is displayed ok and the css file is doing its job with styling etc.
But there are various other problems, for example:
1. There is an image missing from the header
2. The quote button in the header and the content is pointing to the wrong place (quote.php is on the root folder but the button is trying to link to the current subfolder)
3. All of the items on the breadcrumb trail link to the current page
4. All of the links in the footer are also trying to point to the subfolder lightboxes
Is there anything you can think of to fix these issues?
Thanks,
Tony
The URL for the images should be something like this https://www.w-co.co.uk/images/worldpay/visa.gif
You have to use base URL https://www.w-co.co.uk and then image path. You can define("BASE_URL", "https://www.w-co.co.uk") and use it like in the following.
<?php
define("BASE_URL", "https://www.w-co.co.uk/")
?>
<img src="<?php echo BASE_URL;?>images/worldpay/visa.gif"
I want to make multiple pages on my website, but to keep everything clean I want to make different directoriess with the different pages. However, I use php to make a different file with my header that is included in all my pages, so I only have to change the code of my header once and it will be the same on all pages.
The problem is that the links I use in my menu items (like home, contact, about, etc.) will not work anymore when you're on a page inside a directory (I'll make an example below).
So my question:
Is there a home folder on a website (like ~/ on unix) or is there another way to make it work?
Example of my directory structure:
htdocs
index.php
header.php
menus
contact.php
about.php
(a link to index.php won't work anymore if you're on the contact.php page)
Sounds like you're using relative paths in your menu links. Use an absolute path instead by starting with a "/":
Home
About
or a complete URL:
Home
About
The home directory of a website can be accessed with a simple '/' at the start of the link you want to add. From there you can enter subfolders by appending the folder name.
Example:
'example.com/subfolder/subsubfolder/page.html'
Basically I've got pages with a header and footer include, linking to other pages on the main level folder "2015website". Inside the 2015website folder is another folder titled "pick_style". In that folder is a page that has the same exact includes as the pages on the main folder level, except it redirects differently. It will add an extra "2015website" to each link in the url.
Now if I simply just change the header and footer include links and delete the 2015website folder in the link's source, it will fix it for that page, but then breaks it on the main level pages. I'm using php if that has anything to do with it. But I don't know why it's doing that. I need help!
My first post here...I hope that I don't brake any rules and if I do please go easy on me :-)
I have a page a.php with a simple form with one field: name
User puts his/her name and submits. File b.php is in the action field of the form and so it gets the form.
b.php needs to load a slideshow depending on the user input. Let's say there is a folder "clients" and it has folders John and Mary. Each of these folders will have an index file and other sub folders of images, CSS, JS, etc. The index files have relative paths to the subfolders like: ./images/pic1.jpg ./display.css etc.
Here is my problem:
I want to load, say John/index.html without changing the URL that would be xyz.com/b.php
If I use an iFrame the source code will show that xyz.com/clients/John/index.html is loaded and if I use PHP include("xyz.com/clients/John/index.html") then the relative paths that are in the John/index.html won't work.
I am trying to hide the physical location of the slideshow so I can always serve them under the same URL as far as the user can see. Changing relative paths to absolute won't work because that will give away everything that I am trying to hide!
I have simplified the form, folder name, etc. to explain the problem. Could anybody suggest any solutions please.
I don't fully understand the question but <base> may help. It tells the browser to make all links from a page relative to another URL instead of where the page was loaded from
<base href="http://mydomain.com/mybaseurl/" />
I'm making a page as follows, There will be a menu for on the left. In the menu there will be links home, page1, page2, page3 and pageProtected. When I click on any page, this menu will remain unchanged. Only the content of the page on the right will change.
I made a file "left.php" and content of each page as "page1Content.php" etc.
When I click on page1, it takes me to page1.php, which includes left.php and page1Content.php.
Html code...
<?php include("left.php")?>
more html code...
<?php include("page1Content.php")?>
So in each file, only the second included file changes. All the html code are identical for all pages. But I have a protected page, which needs a login window. It is called "pageProtected.php". The thing is I want to keep this file in the main folder, but keep the content: "pageProtectedContent.php" in a folder where I put the .htaccess file.
However when I do this, it doesn't ask password. And when I put "pageProtected.php" in this folder, I have to change "left.php" that I include in this file. Then my purpose of keeping a unique "left.php" is not satisfied. What are my options?
Probably this is a very novice question, but I couldn't find a solution in the internet. Note: I don't want to use frames for the left menu.
.htaccess files only prevent the files from being accessed in a web browser, PHP can include files in htaccess protected folders as if they weren't protected.
I think what you need to do is have pageProtectedContent.php check for a cookie or use php sessions to facilitate login and authentication.
If it is included and the user is not logged in, it will display a login form, if they are logged in, then it will display the protected content.
The only other way to use .htaccess would be to put the protected pages in the protected folder, but you would then need to change your include statements to use ../left.php etc.