Jump to content

Extremely Basic Login/Update Script


dturnbull

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?
Link to comment
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.

Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.