i want to make user registration

neteater

Member
Messages
395
Reaction score
1
Points
18
hi there i want to make an user registration system on my website can any one tell me how to do this step by step like creating a databse conecting it storing user info and most imp thing i want to retrict visitor of my site by playing any online game without being register how to do this the last thing is very important please help me
 

diabolo

Community Advocate
Community Support
Messages
1,682
Reaction score
32
Points
48
creating a user registration system is quite a challenging thing, once you take into consideration everything. A simple one wouldn't be hard, but if you want the security I suggest you use an already created CMS or forum and integrate the member system into your website
 

Zenax

Active Member
Messages
1,377
Reaction score
4
Points
38
Hey,

Creating a members system is not as hard as you think. The basic principle that you are trying to achieve, is to have a website with games on it, but people are only allowed to play the game with having a member account.

One of the ways in which you would achieve this is by using session cookies. You would have a PHP script that would check the username against the cookie to see whether a current user is logged in.

One of the first things that you have to do is to create the MySQL database in which you are going to store usernames, passwords and email addresses or any other information that you might want to have on the registration form.

Start off by going into MySQL admin in your cPanel, and create a new database. You are able to name it whatever you want to, but one of the most simple names would be members or users.

Now you need to set up a connection script to the database. This is achieve like this:

PHP:
mysql_connect ('localhost', 'database Username', 'database password or die ("cannot connect!");
mysql_select_db ('database name') or die ("cannot select database");

That is a basic connection script. all you have to do is change the database username and password to your cPanel username and cPanel password!

The database name would be cPanel username_database name. Example: zenax_members

Once you have this file created, you can then reference it in every file it is required. I am not going to go into any more detail, but if you do a simple google search on PHP Registration tutorial, there are a few decent ones out there that can help you out. Once you followed a tutorial, you can then adapt it to use cookies if it is not discussed in the tutorial.

Hope this is a little bit of help to you!
 
Last edited:

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
250
Points
63
Building on what Zenax said, if you want to make sure the user can't view a page without being logged in you can redirect them like this:

Code:
if(!isset($SESSION['user_logged_in']))
{
     header("location: mywebsite.com");
}

Or display different content
Code:
if(!isset($SESSION['user_logged_in']))
{
     echo "you must be logged in to view this";
}
else
{
     echo "you are logged in!";
}

You would save the $SESSION['user_logged_in'] value if the user's login is correct.

I found a nice article here:

http://www.phpeasystep.com/workshopview.php?id=6

As diabolo said, creating a script is pretty easy, but making a secure and featured script is quite difficult. If you don't understand everything that is happening in your script, you may open a huge hole in your security or close off legitimate users from doing what they want.

Good luck!
 
Last edited:

freecrm

New Member
Messages
629
Reaction score
0
Points
0
OMG... a true registration is lengthy and pretty tricky!!!

I have one on my site...

Form - put in details - JS to validate the form values.

Encrypt data.

Save to DB - send automated email to User.

User validates from e-mail using link.

The a login system has to be done with sessions or cookies - Login page itself and then a check system on each page......

This is not simple and anyone trying to do this without validation is subject to mass spamming problems.

That said, it is a very good way to learn php!

Just try to go through it step by step but don't expect it to be an evenings work!

Due to the number of times this comes up, I think I might do a tutorial (If there isn't one already)
 

xPlozion

New Member
Messages
868
Reaction score
1
Points
0
i've gotta agree with some to say that a user registration is pretty simple. you don't need js, just make sure you check the forms in php ;) i built mine early on in my php learning process, and it was actually easy.

encrypting data is a one line piece of code sha1($pass.$salt); ($salt to make it more secure).

i had a few lines on top of all the code (10 lines max iirc) to check if the user was authenticated to be logged in and to set a few values (id > username, time offset, etc), and this was part of the 10 lines.


what i did was use cookies to set a user_id and a password cookie.
 

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
250
Points
63
i've gotta agree with some to say that a user registration is pretty simple. you don't need js, just make sure you check the forms in php ;) i built mine early on in my php learning process, and it was actually easy.

encrypting data is a one line piece of code sha1($pass.$salt); ($salt to make it more secure).

i had a few lines on top of all the code (10 lines max iirc) to check if the user was authenticated to be logged in and to set a few values (id > username, time offset, etc), and this was part of the 10 lines.


what i did was use cookies to set a user_id and a password cookie.

Encryption is a very good measure, but there are many others that someone new to php might miss. For example, measures must be taken to avoid injection attacks. Valuable data in cookies can be exploited as well. I believe neteater can create a script, but will be be wholly secure?

I would recommend a pre-built script or full tutorial to close every loophole.
 

freecrm

New Member
Messages
629
Reaction score
0
Points
0
I would recommend a pre-built script or full tutorial to close every loophole.

Full agree..

xPlozion - you know what you're doing and scripts like this are relatively easy but to the uninitiated, this can be a little daunting.
 
Top