PHP script runs in one folder but not another
Posted: Sat Aug 14, 2010 4:48 pm
Hello!
I am brand new to PHP, but I'm a software engineer, so it shouldn't be too hard for me. I am trying to use it for a simple HTML form that will send an E-mail to me when a visitor to my web page wants to contact me. I found sample code, and it works -- as long as the PHP script is in the httpdocs folder of my web server. But the web page I got the sample from said it's not a good idea to have the PHP code where it can be retrieved from my site, so I tried moving it to another folder on my server. My provider gives me a folder named "bin" and a folder named "cgi-bin". I tried putting it in cgi-bin. When I opened my test form and clicked the Submit button, I was surprised to see the dialog box asking if I wanted to open or save the file. No, I want it to be run! I tried putting it in the bin folder, but I got "permission denied". But it's my own folder, I think! And its permissions indicate that I should be able to put files in there.
So, a couple of questions: What permissions should the folder containing PHP scripts have? What permissions should the PHP scripts themselves have? Is read permission sufficient, or do they need execute permission as well? I presume that the structure of folders provided by a hosting service to a web site owner is more or less standard. What folder are PHP scripts normally stored in?
Thank you very much!
RobR
I am brand new to PHP, but I'm a software engineer, so it shouldn't be too hard for me. I am trying to use it for a simple HTML form that will send an E-mail to me when a visitor to my web page wants to contact me. I found sample code, and it works -- as long as the PHP script is in the httpdocs folder of my web server. But the web page I got the sample from said it's not a good idea to have the PHP code where it can be retrieved from my site, so I tried moving it to another folder on my server. My provider gives me a folder named "bin" and a folder named "cgi-bin". I tried putting it in cgi-bin. When I opened my test form and clicked the Submit button, I was surprised to see the dialog box asking if I wanted to open or save the file. No, I want it to be run! I tried putting it in the bin folder, but I got "permission denied". But it's my own folder, I think! And its permissions indicate that I should be able to put files in there.
So, a couple of questions: What permissions should the folder containing PHP scripts have? What permissions should the PHP scripts themselves have? Is read permission sufficient, or do they need execute permission as well? I presume that the structure of folders provided by a hosting service to a web site owner is more or less standard. What folder are PHP scripts normally stored in?
Thank you very much!
RobR