Forum Moderators: mack
I'm pretty new to site developing, in fact just built my first one.
I have a question regarding protecting certain pages, here's my config:
My site has a form which collects certain user details. When they click submit, I use PHP to email me the details but to also add them to a text file.
Now here's the problem, I want the text file to be for my use only, however anyone can type in www.site.com/text.txt and it opens up for them! How do I go about protecting the text file so only I can open it up?
Or am I going about things completely the wrong way!
Thanks for your time.
1) Put it above the web root - when you go with FTP you probably have to click into 'html', 'www', 'httpdocs' or similar to get to the directory where your index file goes. Assuming this is the case, put the file ABOVE that directory, i.e. where it is inaccessible via your domain name. Read it by FTP download.
2) Use a MySQL database and store the file in there
3) Rename text.txt to text.php - for security - add <?php die();?> to the top - then anyone who visits will see nothing at all - and when you download via FTP you will get everything.
4) Use a .htpasswd and .htaccess combination - use your favourite Search Engine to find out more about these - they are simple password protection for the directory