tags:

views:

130

answers:

5

PHP make an Admin Area ,to check the User name and Password and then load to another Page

A: 

There are plenty of ways you could achieve this. I recommend using sessions to check if the user logged in with a valid username and password. You can store the usernames and passwords in a database or code it directly in your php-code. Storing your passwords in a database might be a security issue as long as you store them in plain-text. You should use a password hash (created with md5($string)) instead and compare the hashed user input with your database. Just use an HTML-Form where the user enters his name and password, pass the two entered values as session-variables and check whether they match the username and password you stored. If so the desired page can load.

Ham
You should add that passwords shouldn't be stored in plain text in the database. The proper way to do it is to create a hash string of the user's password and store that in the database, then every time the user logs in create a hash from the supplied string and compare it with the one in the database.
Andy E
I first thought about mentioning it but was not sure if it would be too much for the OP. Edited it now.
Ham
+3  A: 

I would suggest learning a CMS like Joomla or Drupal. It takes the headache out of creating admin areas. And, if your asking this question, I think it might be easier than learning to write it in PHP.

RD
We've all gotta start somewhere. The OP might not be interested in abandoning what he's done thus far.
Tim Post
+1  A: 

If you are in a really big hurry, you can try something like PHPMaker. It can examine your database tables and generate the typical create / update / modify / delete forms that you would need to manage users.

Note: I am not endorsing PHPMaker, in fact I really don't care for the code that it actually generates. Its no better and possibly worse than scaffolding provided by MVC frameworks. I posted it as an alternative to telling you 'just use a MVC framework with scaffolding and re-write everything you have done so far'.

However, when lazy, it can be handy.

The real solution is write your own intuitive admin interface.

Tim Post
+1  A: 

Hello,

there's no point in writing this whole code for you. You should try to read some books / articles and then try to code something simple by yourself to see how PHP actually works.

You should check first some simple tutorials first. Like:

Also, consider reading the PHP documentation. There are some nice tips there (also discussions for each topic are usually interesting).

Ondrej Slinták