Reputation: 67
For security reasons I want to have all my connection files to the DB and login files in a folder out of the root directory. Like this:
Project:
includes:
conncect.php
process_login.php
general_files:
index.php
In my index.php i have the following.
<form action="../includes/process_login.php" method="post" name="login_form">
[...]
</form>
The problem is that when i try to submit that form i get an error that says that:
The requested URL /includes/process_login.php was not found on this server.
Does anyone knows a way to do what i want to do?
Upvotes: 1
Views: 4166
Reputation: 4810
It appears that your document root is <Project>/general_files
, and if that's the case, then your process_login.php
file is outside of the public web folder.
You have two options:
1) Move process_login.php
to the general_files/
directory and update the action
attribute accordingly:
Project:
includes:
conncect.php
general_files:
index.php
process_login.php
2) Or add a new PHP file (e.g., new_login.php
) to general_files/
that includes process_login.php
, and set your form's action
attribute to this file:
Project:
includes:
conncect.php
process_login.php
general_files:
index.php
new_login.php
Upvotes: 2
Reputation: 31
As seen here: "to be safe, you should move the include files outside document root, thus making it impossible for the web server to serve them directly." However, to access them, you can use a full path, like so:
include('/home/xx/xx/domains/mydomain/webroot/file-to-include.php');
As seen here.
Upvotes: 3