PDA

View Full Version : Need help on my website...



butter
06 Jul 2010, 12:59 PM
:: Link Removed By Moderator ::
how do I make a login page/registration page?
thanks

<CrGeary.com/>
06 Jul 2010, 04:54 PM
Basically, just make another .php page call its something like: register.php then:

1. Make a HTML form containing fields like:
- Name
- Email
- Password
- Repeat Password

2. Get your Form interacting with the PHP, using the POST ( $_POST ) method.

3. Use that PHP to validate data, and then insert it into the database or XML file or w/e your trying to put it into (assuming its a database) then you would do something like this:

1. Check if all fields are filled out

2. Check to see if the email is the same as another record in the database. Do this by doing a simple select statement like this:
[code]SELECT user_email FROM users WHERE user_email = 'the_email@from_the_form.com' LIMIT 1[code]
Then use mysql_num_rows(); to see if any records where returned, if mysql_num_rows() was 1, then that email exists already, so ask for another.

3. Next check to see if the passwords match, a simple example would be:


if( $_POST['pass1'] != $_POST['pass2'] ){
// Code to say the passwords do not match.
}

4. You also need to validate the email address using a regular expression, and you could probably validate the other fields too.

5. If everything has gone ok so far, and the email is not in the database, then insert a new record into the database, something like this:


mysql_query( "INSERT INTO users ( user_id, user_name, user_email, user_password ) VALUES( NULL, '$name', '$email', '$password' )" );