| |
|
 |
Complete Members System by: bs0d |
Page: 2 of 9 (View All) |
OUTLINE
Here is an outline of the steps we will take to prepare for the script and so on.
- Create members table in database - you can use phpMyAdmin and create the table by hand, or
import SQL, which I will provide.
- Create a register script - If you've going to have members, you need to allow them to signup.
When they do, their information will be stored in the members table.
- Create a login page - At this point, we create a page that will log them into the site and check
their username and password aginst what is stored in the database. Upon success, a cookie will be applied
and the user will be redirected to the main page.
- Modify your page_header - In your page_header code (like from the Site
Design Made Simple tutorial) we will be adding code to check for the cookie to see if
they're logged in.
- Logout - Somewhere on your website, you can display their logged in status with variables we
will setup, but also display a link to logout page, that will log them out. This page will destroy the
session, set the cookie backward and take them back to the main page. If they're not logged in, we can
display a login link and "welcome guest" or something similar.
Just to remind you, this can easily be combined with other scripts/tutorials I have setup that deal with
users on your website, like Users Online and Comments Script. If you get the concept of these tutorials, it wont take much to
do this.
CREATING THE MEMBERS TABLE
To get things started off, our first step is designing the table that our data will be stored into. We
will be storing information so that members can login to the site. So we create a table "members" - Next we
need something to uniquely identify each member (other than username), so we will have a column
called "user_id" - The other two columns we will use are "username" and "user_password". You might want to
add more to yours, like location, interests, etc. This is just a basic example.
Listed below is the SQL code to create the table. You can run that in phpMyAdmin to create the table, or
just create the table using the design I will now explain. The user_id column will auto increment, meaning
each time a member registers, their unique id will automatically be assigned. the username column is set to
varchar(25), meaning that the max length of the character string (username) cannot exceed 25; The
same applies to the user_password column at 32. User email field can be as long as 255. You can change
those to whatever you wish, that is just the way I set them up.
Comments:
| scubby3 |
| Subject: "table"
Date: Mar 16 2008 at 1:15 pm
|
|
|
|
|
where do i
create the
table or place
this code
Code:
-- Table
structure for
table
`members`
--
CREATE TABLE
`members` (
`user_id`
mediumint(8)
NOT NULL
auto_increment,
`username`
varchar(25) NOT
NULL default
'',
`user_password`
varchar(32) NOT
NULL default
'',
`user_email`
varchar(255)
NOT NULL
default
'',
PRIMARY KEY
(`user_id`)
) TYPE=MyISAM
AUTO_INCREMENT=
60 ;
|
| bs0d |
| Subject: "re: table"
Date: Mar 17 2008 at 9:37 am
|
|
|

|
You can
excecute that
in a PHP page,
but first have
to connect to
the database.
Or, you can
download and
install
phpMyAdmin to
manage your
database.
|
| mangoacid |
| Subject: "Great"
Date: Mar 31 2008 at 4:25 pm
|
|
|
|
|
This is an
amazing
tutorial. It
allowed me to
create the
basis for the
restructuring
of my site,
while giving me
a better
understanding
of php
functions.
|
|
|
 |
Tutorial Stats |
| 163,633 |
Views |
| 40 |
Total Comments |
| 4.8 |
Rating of 5 (5 Votes) |
|