PHP Tutorial : Membership script – Users Registration

Hello, I’ve just created a brand new category called Complete Scripts. In this one you will find complete solutions of applications.

The first tutorial is called how to create a membership script with user registration. I will write here a function which will do it! We will have database structure like this :

CREATE TABLE IF NOT EXISTS users (
id int(10) unsigned NOT NULL AUTO_INCREMENT,
user varchar(255) NOT NULL,
pass varchar(255) NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

After this, here is the function to create new users and insert them into database: – first, create a .php page called functions.php

Now we need to create a page with a form where users will type their desired user & pass (please note we need to include database connection file and functions one:

PS : For database connection please remember here

Tagged with: , , , , , , , , ,
Posted in Complete Scripts
2 comments on “PHP Tutorial : Membership script – Users Registration
  1. bogdan says:

    A few mistakes in this script that I must point out.

    First of all, you’ve missed out the closing curly bracket in the first function.

    Second of all, mysql will return an error when trying to insert the new row, because the script will be something like “insert into values(“. You declare the $tableUsers variable outside the function but don’t declare it as a global variable inside the function, so it will not be recognised.

    Last, but very important (though it might not seem like it), you’re storing the passwords in the database in clear text. A fundamental error which I highly discourage at every chance I have. It’s one of the basic rules of website security. Encrypt the users’ passwords, at the very least with an md5 or sha1, if not using something more advanced.

  2. admin says:

    Firstly of all,
    Let me thank you for your time spent here and really analyzing my content.
    We’re humans and we’re making mistakes: I am writing on this blog in a hurry because I got customers your input really helps.
    Also, here you’re learning basic php, not security techniques, if I will start and validate everything the newbie will run away from my blog in a NewYork Minute. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

*