View Full Version : Someone help with members script

09-10-2005, 02:32 AM
i basically want to make a script that includes the following functions:
1. Registration
2. Username
3. Password

You know the basic thing. Help? :confused:

And just so you know im new to php so make it as simplisfied as you can (not the script the explanation) the script can be as long and advanced as you choose but please if possible make it so i can cut and paste it and itll work. :thumbsup: thx

09-10-2005, 06:13 AM
That's a long script you want there. I would do it, but I am... lazy. :P Sorry. I am also working on my own script.

But I suggest that you download a user system script and check out the files. It should basically have anything you need to know.

Here's a basic user database:
Database Name: users
username VARCHAR( 255 ) NOT NULL (unique)
password VARCHAR( 255 ) NOT NULL

Now, for login.php, you just do an if statement that checks for either a logged_in session or a logged_in AND username cookie. If either or both exist, you redirect (header('location: page.php')) to another page. if not, display a form. Then, you do an if around the form that says if(!$HTTP_POST_VARS['submit']) and then when you get to else, which would run if you submit the form, you put an sql check to see if the username and password are correct. If so, create the session and cookie variables stated above (google if you don't know how!). If not, show an error and give them a link to go back.

For register.php, do an if that asks whether or not the form has been submitted. If not, show the form. You need at least a username, and password field (if you put more, then you have to add more fields to the database too!), and a submit button. If the form has been submitted, you do a check to make sure that the username has not been taken, if it hasn't make the account, if it has, show an error and let them go back.

You can add a good deal more code if you want email varification, but you said simple and I'm lazy right now so I won't tell you how (not trying to be mean or anything).

Anyways... that's the most basic member script. BUT you need to remember to put mysql_real_escape_string(...) around every single variable with which you run a SELECT, or else it won't be too hard for someone to hack into your members area.

Oh, and if you want some members only pages, remember to put a check for the session and cookie variables at the top of each of those pages. If there are no session or cookie variables set, then have it redirect to the login form. If there are, then the user's all clear! ;)

If you need anything else, just ask. (I'm sure there are tutorials somewhere. If not, I may make up a short members area tutorial sometime soon.)


09-10-2005, 08:27 PM
it would help that if your done with whatever you are currently working on you help me with the script because im new to php im currently only using html. i undertsand that your lazy (i am too) but when you get a chance please make a downloadable version of the script and a .txt version of the databse setup. thx :thumbsup: