Jump to content

Archived

This topic is now archived and is closed to further replies.

dturnbull

Extremely Basic Login/Update Script

Recommended Posts

I have a really simple database/script.
Users sign up with an email, username, and password (and some other fields), and then a new page is created for them with their details.

Could someone give me some help on how to make it so users can use their email/password to login then update their details?

Share this post


Link to post
Share on other sites
[!--quoteo(post=373416:date=May 13 2006, 02:14 PM:name=David Turnbull)--][div class=\'quotetop\']QUOTE(David Turnbull @ May 13 2006, 02:14 PM) [snapback]373416[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I have a really simple database/script.
Users sign up with an email, username, and password (and some other fields), and then a new page is created for them with their details.

Could someone give me some help on how to make it so users can use their email/password to login then update their details?
[/quote]


I can not write the entire code for you, but here is the designing:

1. Set up your database, make sure all the field names and field datatypes are good in place.
2. Write a Register.php file. This page contain a registration form for new user to register. Registration will be consistent with the fields in your database table.
3. Write a Login.php file. This file contain a login form (username and password). when click submit, it will check against database. If verified, redirect to the profile.php, otherwise, stay on the same login with a message.
4. the profile.php, This file contain a very similar form as registration, but instead with a update button at the bottom. profile.php first read the data for this user from db, then parse them to the form.

Share this post


Link to post
Share on other sites
How would I check the username/password against the database? that is wat I am having troubles with.

Share this post


Link to post
Share on other sites
[!--quoteo(post=373427:date=May 13 2006, 03:41 PM:name=David Turnbull)--][div class=\'quotetop\']QUOTE(David Turnbull @ May 13 2006, 03:41 PM) [snapback]373427[/snapback][/div][div class=\'quotemain\'][!--quotec--]
How would I check the username/password against the database? that is wat I am having troubles with.
[/quote]

this is where sql come in.

One most common way to do this, is to query the database, check to see if there exist a record with that given username and given password.

if there is, then the username and password match, since username is unique, there is only 1 record that able to match a given username and password.

sample query:

$rs = mysql_query("select count(*) as count from tablename where username='$username' and password='$password'");

if (mysql_num_rows($rs) == 1)
{
echo 'password and username is correct';
}
else
{
echo 'password username did not match';
}

tablename is the table in db that contain user registration information.
$username, $password are retrieve from login form.

Share this post


Link to post
Share on other sites
There are TONS of simple membership tutorials on the net. Take one.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.