Page 1 of 1

User Access In PHP

Posted: Thu Jul 14, 2011 8:33 am
by Munnabhaai
Hi,

I am new to PHP and currently trying to develop a website. I have a few sections (pages) where Users must insert a Username and password to gain access to other pages. i want to use PHP for doing that.

e.g. loginstaff.htm - user has to enter Username & Password (this is being validated by a php script in login.php) to access staff.htm. I need the user to enter the proper Username & password used when registering and restrict any other people/user to type the URL directly (e.g. www.site.com/staff.htm).

Thanks
Munnabhaai

Re: User Access In PHP

Posted: Thu Jul 14, 2011 8:40 am
by Celauran
What do you have so far? What problems are you encountering?

Re: User Access In PHP

Posted: Thu Jul 14, 2011 1:27 pm
by califdon
Munnabhaai wrote:Hi,

I am new to PHP and currently trying to develop a website. I have a few sections (pages) where Users must insert a Username and password to gain access to other pages. i want to use PHP for doing that.

e.g. loginstaff.htm - user has to enter Username & Password (this is being validated by a php script in login.php) to access staff.htm. I need the user to enter the proper Username & password used when registering and restrict any other people/user to type the URL directly (e.g. http://www.site.com/staff.htm).

Thanks
Munnabhaai
First of all, in order to use PHP, you need to eliminate staff.htm and replace it with staff.php, which will contain all the html from staff.htm, but will have additional PHP code to control the access, etc. At least, I think that's the most obvious and efficient approach. So staff.php will initially present the user with a login form that has action='', which sends the Post form data back to the same script, which can then validate the login credentials against the database and either deliver the desired HTML or return the notice that the login was unsuccessful.

Re: User Access In PHP

Posted: Fri Jul 15, 2011 3:20 am
by Munnabhaai
califdon

thanks will start doing that and get back for more questions that i may have.

Thanks