0

I am trying to link an action within a form to a php script:

<form action='../includes/RC_APP/process_login.php' method="post" name="login_form">

However it comes back with the error: The requested URL /includes/RC_APP/process_login.php was not found on this server.

The PHP includes work fine:

<?php
include_once '../includes/RC_APP/db_connect.php';
include_once '../includes/RC_APP/functions.php';

My only thoughts are that the HTML will not process access above the web server document root directory while the PHP will; but this contradicts the security advice on keeping PHP include files outside of the web server's document root.

Any advice would be greatly appreciated.

Roddy
  • 2,018
  • 3
  • 16
  • 21
  • use base path and then your directory and file name. – Awlad Liton Feb 22 '14 at 03:52
  • Thanks, I thought basepath as a PHP function rather than an HTML one; will look it up and try to clarify. – Roddy Feb 22 '14 at 03:57
  • Why are you posting directly to a file within an includes directory? seems a bit odd.. – Ohgodwhy Feb 22 '14 at 04:00
  • I am setting up a login process for the first time and following on from quite a lot of different advice, mainly utilising the approach put forward on http://www.wikihow.com/Create-a-Secure-Login-Script-in-PHP-and-MySQL. – Roddy Feb 22 '14 at 04:02
  • @AwladLiton have been looking through the uses of base path and I am not following your suggestion; would you be able to elaborate on how you are suggesting the use of base path in the form action? – Roddy Feb 22 '14 at 04:05

2 Answers2

0

you need to set base path in the head section.

like this:

<head>
<base href="your_site/sub_directory/">
</head>

The base tag makes everything link differently, including same-page anchor links to the base tag's url instead, e.g:

<a href='?update=1'>A link to this page</a>

becomes

<a href='your_site/sub_directory/?update=1' title='Some title'>A link to the base tag's page instead</a>

if you need to go another folder in same directory in base path e.g a folder includes in the basepath directory link that in this way :

 <a href='includes/'>A link to this page</a>

if you need to go another parent folder of base path e.g a folder includes :

 <a href='..includes/'>A link to this page</a>

see more details: Is it recommended to use the <base> html tag?

Community
  • 1
  • 1
Awlad Liton
  • 9,366
  • 2
  • 27
  • 53
  • Hi, thanks for the answer but I am not sure how this would alleviate the issue as it is not a sub-directory of the document root that is the issue but a directory above the document root. Even with the Base tag in the Head of the HTML, the error is the same; it seems to be dropping the ../ parent specifier. – Roddy Feb 22 '14 at 04:31
  • I think I have found the answer to my question, in that a form action cannot access anything above the document root directory: http://stackoverflow.com/questions/11390420/html-form-action-using-a-php-file-outside-of-root-directory – Roddy Feb 22 '14 at 04:47
0

I think I have found the answer to my question, in that a form action cannot access anything above the document root directory:

HTML form action using a php file outside of root directory?

Community
  • 1
  • 1
Roddy
  • 2,018
  • 3
  • 16
  • 21
  • By including a local PHP file that included a link to the actual script, as suggested by the linked Stack Overflow topic, the page is now working. Thanks to everyone for their help and suggestions. – Roddy Feb 22 '14 at 04:59