Jump to content

Making secure


Leadwing

Recommended Posts

Hi there,

I have an admin section to my website, where you are required to provide a username and password, and retrieves the username and password from a database. My questions are:

 

1. How do I make the following pages innacessible without logging in first? Would a simple session work?

 

2. Surely someone could just download the files from my website and find out the username and password required to access the database? This is the same for other parts of the site, in the PHP code I specify my username and password to access a database... Surely this is very insecure?

 

Thanks :)

Link to comment
Share on other sites

There is a very useful guide http://www.php-mysql-tutorial.com/user-authentication/index.php which shows you how to authenticate users using usernames and passwords from a database and sessions.

 

I have used it for user login on my site, and have found it extremely helpful.

 

Im not sure about the second question as I am not particularly knowledgeable about security, but the above link should point you in the right direction.

Link to comment
Share on other sites

[NOT IN ORDER?]

 

a) All PHP files served by a server should get processed by the PHP interpreter and will only display any HTML (etc) that the PHP code outputs. So technically no people can't just download your PHP pages.

 

b) Once you have some kind of system to login, then you use some logic like this:

if($logged_in==1)
{
print "Hi user";
}
else
{
print "Who the f are you?";
}

Link to comment
Share on other sites

When you view or save a page, it may have the '.php' extension or the like, but that page should have been parsed by the server and contain no php, if there is it's either because the server is setup incorrectly or the code is buggy.

 

A web browser simply downloads a page, then scans it for any resource links it may contain (images, frame links, rss feed, adverts, etc) and also downloads them, then it renders it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.