Search
Left Quote    I find that the harder I work, the more luck I seem to have.
- Thomas Jefferson    
Right Quote
 
[login] | [Register]
 

Complete Members System

by: bs0d
Page: 5 of 9
(View All)

The next step I chose was to take the valid username entered, and see if it is already taken. See code below:


Query the members table where username from table = entered username. The if condition checks if $q3->username (from database) is equal to the desired username ($_POST['username']). If there is a match, someone already has the username, and and error will be displayed.

PASSWORD

Next in line is the password and verify password fields. It is important that they know what their password will be, and that the verify password field matches the password field. So in the code, we check exactly that. Take a look:


Four tests here: check if password field is empty, check if verify password field is empty, check if password is equal to verify password, and check if the password is less than six characters in length. If any of these conditions are met, an error will be displayed. Any password that passes through this, is considered to be acceptable for insertion. We dont check the password for oddball characters, because having them will actually increase the strength of their password.

INSERTING A NEW MEMBER

Now that we're this far, we are ready to add a member. This tutorial only checked the username and password (most important), but you might want to take it a step further to see if there is a valid email address or something else. Below is the code to insert the new member:


Basic insertion query: inserting into members table, then the column fields of the table to insert into, and finally the values to put into the column fields of the member table. Tha values are from the form the user filled out, and are accessed by $_POST method. Notice md5() function on the password. This is an encryption, so that the password is more secure and safe in the database, than just the password itself. In the login script, we will md5 the entered password and check it aginst the md5 password in the database. They will match if the entered passwords are the same.

Last step, is to display the form. Basic HTML form is all you need. Im sure more advanced ways exist, but we'll go with what we know works for now.



Thats an example of what you might use (above). Form action is set to PHP_SELF and method is POST. The name of the input boxes will be represenative of the $_POST value (input id = username, then $_POST['username'] is the value for values in that input box).

That is the end of the registration script. If everything was a success, the registration successful message will appear and your member can now login. So, we must create a login script for them next!




1  |  2  |  3  |  4  |  5  |  6  |  7  |  8  |  9  |  
Next »


No Comments for this page.

You Must be logged in or a member to comment.


Tutorial Stats

Tutorial Stats

330,939 Views
41 Total Comments
4.8 Rating of 5 (5 Votes)

Options

Tutorial Options

· Login to Rate This Article
· Login to Post a Comment
· Read more by this author
Digg This Article! Del.icio.us: Bookmark This Article Reddit: Bookmark This Article BlinkList: Blink This Article! YahooMyWeb BlogMarks: Add This Mark! Furl: Save This Article Spurl: Mark This Article

Articles

Related    

· Simple PHP Tutorial
· One File Website
· Pagination with PHP
· Building a Comments Script
· Variable Scope



"AllSyntax.com" Copyright © 2002-2017; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank