Confusion regarding file structure of PHP/ HTML project (with a form)










0














Below is the file structure of my website on the domain server (not localhost):



public_html
--- index.html
real-estate-website
--- resources
--- --- sign_up.php


I have a form in my index.html file that points to...



../real-estate-website/resources/sign_up.php


I have tried adding a ./ before this, but it made no difference. When I submit the form from my domain, I get a 404 error, with the following url in the address bar:



[domain-name]/real-estate-website/resources/sign_up.php


Is there an issue with where the form is pointing or am I overlooking something else? Any help is appreciated. Let me know if I should clarify any part of my question










share|improve this question





















  • Is public_html the webroot? If so the folder your trying to access is outside it. Plop the real-estate-website folder into public_html
    – Lawrence Cherone
    Nov 12 '18 at 0:43











  • I am pretty sure it is the webroot. How would I get around this issue then?
    – Shivang Patel
    Nov 12 '18 at 0:44















0














Below is the file structure of my website on the domain server (not localhost):



public_html
--- index.html
real-estate-website
--- resources
--- --- sign_up.php


I have a form in my index.html file that points to...



../real-estate-website/resources/sign_up.php


I have tried adding a ./ before this, but it made no difference. When I submit the form from my domain, I get a 404 error, with the following url in the address bar:



[domain-name]/real-estate-website/resources/sign_up.php


Is there an issue with where the form is pointing or am I overlooking something else? Any help is appreciated. Let me know if I should clarify any part of my question










share|improve this question





















  • Is public_html the webroot? If so the folder your trying to access is outside it. Plop the real-estate-website folder into public_html
    – Lawrence Cherone
    Nov 12 '18 at 0:43











  • I am pretty sure it is the webroot. How would I get around this issue then?
    – Shivang Patel
    Nov 12 '18 at 0:44













0












0








0







Below is the file structure of my website on the domain server (not localhost):



public_html
--- index.html
real-estate-website
--- resources
--- --- sign_up.php


I have a form in my index.html file that points to...



../real-estate-website/resources/sign_up.php


I have tried adding a ./ before this, but it made no difference. When I submit the form from my domain, I get a 404 error, with the following url in the address bar:



[domain-name]/real-estate-website/resources/sign_up.php


Is there an issue with where the form is pointing or am I overlooking something else? Any help is appreciated. Let me know if I should clarify any part of my question










share|improve this question













Below is the file structure of my website on the domain server (not localhost):



public_html
--- index.html
real-estate-website
--- resources
--- --- sign_up.php


I have a form in my index.html file that points to...



../real-estate-website/resources/sign_up.php


I have tried adding a ./ before this, but it made no difference. When I submit the form from my domain, I get a 404 error, with the following url in the address bar:



[domain-name]/real-estate-website/resources/sign_up.php


Is there an issue with where the form is pointing or am I overlooking something else? Any help is appreciated. Let me know if I should clarify any part of my question







php html path filepath






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 12 '18 at 0:38









Shivang Patel

5919




5919











  • Is public_html the webroot? If so the folder your trying to access is outside it. Plop the real-estate-website folder into public_html
    – Lawrence Cherone
    Nov 12 '18 at 0:43











  • I am pretty sure it is the webroot. How would I get around this issue then?
    – Shivang Patel
    Nov 12 '18 at 0:44
















  • Is public_html the webroot? If so the folder your trying to access is outside it. Plop the real-estate-website folder into public_html
    – Lawrence Cherone
    Nov 12 '18 at 0:43











  • I am pretty sure it is the webroot. How would I get around this issue then?
    – Shivang Patel
    Nov 12 '18 at 0:44















Is public_html the webroot? If so the folder your trying to access is outside it. Plop the real-estate-website folder into public_html
– Lawrence Cherone
Nov 12 '18 at 0:43





Is public_html the webroot? If so the folder your trying to access is outside it. Plop the real-estate-website folder into public_html
– Lawrence Cherone
Nov 12 '18 at 0:43













I am pretty sure it is the webroot. How would I get around this issue then?
– Shivang Patel
Nov 12 '18 at 0:44




I am pretty sure it is the webroot. How would I get around this issue then?
– Shivang Patel
Nov 12 '18 at 0:44












1 Answer
1






active

oldest

votes


















1














Usually in a web hosting provider server, public_html is the folder where you put all your files that should be accessible to the users of your website (through a web browser), any file outside of this folder is not accessible directly from a web browser, unless you use some PHP code to deliver it in some way.



Here you are using an HTML form and using its action attribute which should always point to an accessible file, i.e. a file inside public_html.



My suggestion is to move the folder real-estate-website with its content inside the public_html folder.



public_html
--- index.html
--- real-estate-website
--- --- resources
--- --- --- sign_up.php


And change the action attribute value of the form to point to your desired file: /real-estate-website/resources/sign_up.php.



UPDATE



Regarding the comments below what I meant with PHP include is for example to create a PHP file outside public_html :



public_html
--- index.html
--- real-estate-website
--- --- resources
--- --- --- sign_up.php
config
--- settings.php


In settings.php you put the sensitive data:



<?php
const EMAIL_PWD = 'secret';


And in your sign_up.php include settings.php in the top of your code like this:



<?php
include __DIR__ . '/../config/settings.php';


So inside your sign_up.php code you should have access to the string constant EMAIL_PWD and use it accordingly.






share|improve this answer






















  • Are you sure my files are secure even if I move them inside the public_html folder? I am asking this because some of my other php files contain passwords and validation to other parts of my website.
    – Shivang Patel
    Nov 12 '18 at 0:50






  • 1




    Hi, for security reasons, things like passwords and other sensitive data should effectively be outside of the web root (public_html) folder, and use PHP e.g. include to include files defining them, or parse_ini_file if you choose to put them in an .ini file, you can go further with this and put only the files which contains minimum logic and HTML mostly in the public_html, and from them include other files containing logic like controllers, entities, functions etc. which will be outside of public_html.
    – ankabout
    Nov 12 '18 at 0:57










  • I'm still confused on how I would apply this to my scenario. My form in index.html submits to sign_up.php which sends an email. The email function contains the password to an email account, so as per what you said, I can't have this in public_html. How would I use 'include' in this scenario?
    – Shivang Patel
    Nov 12 '18 at 1:05






  • 1




    Normally even if you put a password inside a PHP file which is inside the public_html it should be hard to display it you don't echo yourself in the code. The hacker must actually find a way to display the actual code written in sign_up.php in order to see the password. I'm not a security expert but it seems to me a hard task to achieve unless getting access to the server I don't know.
    – ankabout
    Nov 12 '18 at 1:12






  • 1




    @ShivangPatel You could also see my answer edit to a possible use of include.
    – ankabout
    Nov 12 '18 at 1:21










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53254669%2fconfusion-regarding-file-structure-of-php-html-project-with-a-form%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Usually in a web hosting provider server, public_html is the folder where you put all your files that should be accessible to the users of your website (through a web browser), any file outside of this folder is not accessible directly from a web browser, unless you use some PHP code to deliver it in some way.



Here you are using an HTML form and using its action attribute which should always point to an accessible file, i.e. a file inside public_html.



My suggestion is to move the folder real-estate-website with its content inside the public_html folder.



public_html
--- index.html
--- real-estate-website
--- --- resources
--- --- --- sign_up.php


And change the action attribute value of the form to point to your desired file: /real-estate-website/resources/sign_up.php.



UPDATE



Regarding the comments below what I meant with PHP include is for example to create a PHP file outside public_html :



public_html
--- index.html
--- real-estate-website
--- --- resources
--- --- --- sign_up.php
config
--- settings.php


In settings.php you put the sensitive data:



<?php
const EMAIL_PWD = 'secret';


And in your sign_up.php include settings.php in the top of your code like this:



<?php
include __DIR__ . '/../config/settings.php';


So inside your sign_up.php code you should have access to the string constant EMAIL_PWD and use it accordingly.






share|improve this answer






















  • Are you sure my files are secure even if I move them inside the public_html folder? I am asking this because some of my other php files contain passwords and validation to other parts of my website.
    – Shivang Patel
    Nov 12 '18 at 0:50






  • 1




    Hi, for security reasons, things like passwords and other sensitive data should effectively be outside of the web root (public_html) folder, and use PHP e.g. include to include files defining them, or parse_ini_file if you choose to put them in an .ini file, you can go further with this and put only the files which contains minimum logic and HTML mostly in the public_html, and from them include other files containing logic like controllers, entities, functions etc. which will be outside of public_html.
    – ankabout
    Nov 12 '18 at 0:57










  • I'm still confused on how I would apply this to my scenario. My form in index.html submits to sign_up.php which sends an email. The email function contains the password to an email account, so as per what you said, I can't have this in public_html. How would I use 'include' in this scenario?
    – Shivang Patel
    Nov 12 '18 at 1:05






  • 1




    Normally even if you put a password inside a PHP file which is inside the public_html it should be hard to display it you don't echo yourself in the code. The hacker must actually find a way to display the actual code written in sign_up.php in order to see the password. I'm not a security expert but it seems to me a hard task to achieve unless getting access to the server I don't know.
    – ankabout
    Nov 12 '18 at 1:12






  • 1




    @ShivangPatel You could also see my answer edit to a possible use of include.
    – ankabout
    Nov 12 '18 at 1:21















1














Usually in a web hosting provider server, public_html is the folder where you put all your files that should be accessible to the users of your website (through a web browser), any file outside of this folder is not accessible directly from a web browser, unless you use some PHP code to deliver it in some way.



Here you are using an HTML form and using its action attribute which should always point to an accessible file, i.e. a file inside public_html.



My suggestion is to move the folder real-estate-website with its content inside the public_html folder.



public_html
--- index.html
--- real-estate-website
--- --- resources
--- --- --- sign_up.php


And change the action attribute value of the form to point to your desired file: /real-estate-website/resources/sign_up.php.



UPDATE



Regarding the comments below what I meant with PHP include is for example to create a PHP file outside public_html :



public_html
--- index.html
--- real-estate-website
--- --- resources
--- --- --- sign_up.php
config
--- settings.php


In settings.php you put the sensitive data:



<?php
const EMAIL_PWD = 'secret';


And in your sign_up.php include settings.php in the top of your code like this:



<?php
include __DIR__ . '/../config/settings.php';


So inside your sign_up.php code you should have access to the string constant EMAIL_PWD and use it accordingly.






share|improve this answer






















  • Are you sure my files are secure even if I move them inside the public_html folder? I am asking this because some of my other php files contain passwords and validation to other parts of my website.
    – Shivang Patel
    Nov 12 '18 at 0:50






  • 1




    Hi, for security reasons, things like passwords and other sensitive data should effectively be outside of the web root (public_html) folder, and use PHP e.g. include to include files defining them, or parse_ini_file if you choose to put them in an .ini file, you can go further with this and put only the files which contains minimum logic and HTML mostly in the public_html, and from them include other files containing logic like controllers, entities, functions etc. which will be outside of public_html.
    – ankabout
    Nov 12 '18 at 0:57










  • I'm still confused on how I would apply this to my scenario. My form in index.html submits to sign_up.php which sends an email. The email function contains the password to an email account, so as per what you said, I can't have this in public_html. How would I use 'include' in this scenario?
    – Shivang Patel
    Nov 12 '18 at 1:05






  • 1




    Normally even if you put a password inside a PHP file which is inside the public_html it should be hard to display it you don't echo yourself in the code. The hacker must actually find a way to display the actual code written in sign_up.php in order to see the password. I'm not a security expert but it seems to me a hard task to achieve unless getting access to the server I don't know.
    – ankabout
    Nov 12 '18 at 1:12






  • 1




    @ShivangPatel You could also see my answer edit to a possible use of include.
    – ankabout
    Nov 12 '18 at 1:21













1












1








1






Usually in a web hosting provider server, public_html is the folder where you put all your files that should be accessible to the users of your website (through a web browser), any file outside of this folder is not accessible directly from a web browser, unless you use some PHP code to deliver it in some way.



Here you are using an HTML form and using its action attribute which should always point to an accessible file, i.e. a file inside public_html.



My suggestion is to move the folder real-estate-website with its content inside the public_html folder.



public_html
--- index.html
--- real-estate-website
--- --- resources
--- --- --- sign_up.php


And change the action attribute value of the form to point to your desired file: /real-estate-website/resources/sign_up.php.



UPDATE



Regarding the comments below what I meant with PHP include is for example to create a PHP file outside public_html :



public_html
--- index.html
--- real-estate-website
--- --- resources
--- --- --- sign_up.php
config
--- settings.php


In settings.php you put the sensitive data:



<?php
const EMAIL_PWD = 'secret';


And in your sign_up.php include settings.php in the top of your code like this:



<?php
include __DIR__ . '/../config/settings.php';


So inside your sign_up.php code you should have access to the string constant EMAIL_PWD and use it accordingly.






share|improve this answer














Usually in a web hosting provider server, public_html is the folder where you put all your files that should be accessible to the users of your website (through a web browser), any file outside of this folder is not accessible directly from a web browser, unless you use some PHP code to deliver it in some way.



Here you are using an HTML form and using its action attribute which should always point to an accessible file, i.e. a file inside public_html.



My suggestion is to move the folder real-estate-website with its content inside the public_html folder.



public_html
--- index.html
--- real-estate-website
--- --- resources
--- --- --- sign_up.php


And change the action attribute value of the form to point to your desired file: /real-estate-website/resources/sign_up.php.



UPDATE



Regarding the comments below what I meant with PHP include is for example to create a PHP file outside public_html :



public_html
--- index.html
--- real-estate-website
--- --- resources
--- --- --- sign_up.php
config
--- settings.php


In settings.php you put the sensitive data:



<?php
const EMAIL_PWD = 'secret';


And in your sign_up.php include settings.php in the top of your code like this:



<?php
include __DIR__ . '/../config/settings.php';


So inside your sign_up.php code you should have access to the string constant EMAIL_PWD and use it accordingly.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 12 '18 at 1:21

























answered Nov 12 '18 at 0:47









ankabout

668210




668210











  • Are you sure my files are secure even if I move them inside the public_html folder? I am asking this because some of my other php files contain passwords and validation to other parts of my website.
    – Shivang Patel
    Nov 12 '18 at 0:50






  • 1




    Hi, for security reasons, things like passwords and other sensitive data should effectively be outside of the web root (public_html) folder, and use PHP e.g. include to include files defining them, or parse_ini_file if you choose to put them in an .ini file, you can go further with this and put only the files which contains minimum logic and HTML mostly in the public_html, and from them include other files containing logic like controllers, entities, functions etc. which will be outside of public_html.
    – ankabout
    Nov 12 '18 at 0:57










  • I'm still confused on how I would apply this to my scenario. My form in index.html submits to sign_up.php which sends an email. The email function contains the password to an email account, so as per what you said, I can't have this in public_html. How would I use 'include' in this scenario?
    – Shivang Patel
    Nov 12 '18 at 1:05






  • 1




    Normally even if you put a password inside a PHP file which is inside the public_html it should be hard to display it you don't echo yourself in the code. The hacker must actually find a way to display the actual code written in sign_up.php in order to see the password. I'm not a security expert but it seems to me a hard task to achieve unless getting access to the server I don't know.
    – ankabout
    Nov 12 '18 at 1:12






  • 1




    @ShivangPatel You could also see my answer edit to a possible use of include.
    – ankabout
    Nov 12 '18 at 1:21
















  • Are you sure my files are secure even if I move them inside the public_html folder? I am asking this because some of my other php files contain passwords and validation to other parts of my website.
    – Shivang Patel
    Nov 12 '18 at 0:50






  • 1




    Hi, for security reasons, things like passwords and other sensitive data should effectively be outside of the web root (public_html) folder, and use PHP e.g. include to include files defining them, or parse_ini_file if you choose to put them in an .ini file, you can go further with this and put only the files which contains minimum logic and HTML mostly in the public_html, and from them include other files containing logic like controllers, entities, functions etc. which will be outside of public_html.
    – ankabout
    Nov 12 '18 at 0:57










  • I'm still confused on how I would apply this to my scenario. My form in index.html submits to sign_up.php which sends an email. The email function contains the password to an email account, so as per what you said, I can't have this in public_html. How would I use 'include' in this scenario?
    – Shivang Patel
    Nov 12 '18 at 1:05






  • 1




    Normally even if you put a password inside a PHP file which is inside the public_html it should be hard to display it you don't echo yourself in the code. The hacker must actually find a way to display the actual code written in sign_up.php in order to see the password. I'm not a security expert but it seems to me a hard task to achieve unless getting access to the server I don't know.
    – ankabout
    Nov 12 '18 at 1:12






  • 1




    @ShivangPatel You could also see my answer edit to a possible use of include.
    – ankabout
    Nov 12 '18 at 1:21















Are you sure my files are secure even if I move them inside the public_html folder? I am asking this because some of my other php files contain passwords and validation to other parts of my website.
– Shivang Patel
Nov 12 '18 at 0:50




Are you sure my files are secure even if I move them inside the public_html folder? I am asking this because some of my other php files contain passwords and validation to other parts of my website.
– Shivang Patel
Nov 12 '18 at 0:50




1




1




Hi, for security reasons, things like passwords and other sensitive data should effectively be outside of the web root (public_html) folder, and use PHP e.g. include to include files defining them, or parse_ini_file if you choose to put them in an .ini file, you can go further with this and put only the files which contains minimum logic and HTML mostly in the public_html, and from them include other files containing logic like controllers, entities, functions etc. which will be outside of public_html.
– ankabout
Nov 12 '18 at 0:57




Hi, for security reasons, things like passwords and other sensitive data should effectively be outside of the web root (public_html) folder, and use PHP e.g. include to include files defining them, or parse_ini_file if you choose to put them in an .ini file, you can go further with this and put only the files which contains minimum logic and HTML mostly in the public_html, and from them include other files containing logic like controllers, entities, functions etc. which will be outside of public_html.
– ankabout
Nov 12 '18 at 0:57












I'm still confused on how I would apply this to my scenario. My form in index.html submits to sign_up.php which sends an email. The email function contains the password to an email account, so as per what you said, I can't have this in public_html. How would I use 'include' in this scenario?
– Shivang Patel
Nov 12 '18 at 1:05




I'm still confused on how I would apply this to my scenario. My form in index.html submits to sign_up.php which sends an email. The email function contains the password to an email account, so as per what you said, I can't have this in public_html. How would I use 'include' in this scenario?
– Shivang Patel
Nov 12 '18 at 1:05




1




1




Normally even if you put a password inside a PHP file which is inside the public_html it should be hard to display it you don't echo yourself in the code. The hacker must actually find a way to display the actual code written in sign_up.php in order to see the password. I'm not a security expert but it seems to me a hard task to achieve unless getting access to the server I don't know.
– ankabout
Nov 12 '18 at 1:12




Normally even if you put a password inside a PHP file which is inside the public_html it should be hard to display it you don't echo yourself in the code. The hacker must actually find a way to display the actual code written in sign_up.php in order to see the password. I'm not a security expert but it seems to me a hard task to achieve unless getting access to the server I don't know.
– ankabout
Nov 12 '18 at 1:12




1




1




@ShivangPatel You could also see my answer edit to a possible use of include.
– ankabout
Nov 12 '18 at 1:21




@ShivangPatel You could also see my answer edit to a possible use of include.
– ankabout
Nov 12 '18 at 1:21

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53254669%2fconfusion-regarding-file-structure-of-php-html-project-with-a-form%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo