Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
change account details w/ email confirmation
Old 06-07-2009, 08:44 PM change account details w/ email confirmation
Extreme Talker

Posts: 176
Trades: 0
I already have a site with users and everything.

I want to allow users to change their e-mail and passwords, but I want them to have to confirm it through e-mail.

I'm just not really sure how I should go about it.

I was considering generating a random string, then sending them an e-mail with a link containing that code, but that would require me to add 2 extra fields to the users table, one for the code and one for new e-mail/password, which seems like a waste.

Any one done this before, or have any suggestions?

I'm using php4 and mysql. This is more of a psuedocode question, rather than php, considering I'm fairly good with php.
Skeddles is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-07-2009, 09:03 PM Re: change account details w/ email confirmation
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Rather than adding rows to the existing user table, you could create a user meta data table to store more generic data. Each row would contain a user id, a meta key, and a meta value. When a user needs to change their password, you can store the confirmation code in the meta data table and remove it after confirmation.

Given the following table structure
Code:
id | user id | meta key | meta value
0  | 1       | confirm  | randomstring
and the following URL
Code:
http://yoursite.com/verify.php?id=1&value=randomstring
verify.php
PHP Code:
$id $_GET['id'];
$value $_GET['value'];
//don't forget to sanitize this data

$query "SELECT COUNT(*) FROM meta_data
WHERE meta_key = 'confirm' AND user_id = '
$id' AND meta_value = '$value';";
.
.

As I mentioned, this method allows you to store generic data which is good if you plan to make future changes.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by NullPointer; 06-07-2009 at 09:04 PM..
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 06-07-2009, 10:28 PM Re: change account details w/ email confirmation
Extreme Talker

Posts: 176
Trades: 0
Quote:
Originally Posted by NullPointer View Post
Rather than adding rows to the existing user table, you could create a user meta data table to store more generic data. Each row would contain a user id, a meta key, and a meta value. When a user needs to change their password, you can store the confirmation code in the meta data table and remove it after confirmation.

Given the following table structure
Code:
id | user id | meta key | meta value
0  | 1       | confirm  | randomstring
and the following URL
Code:
http://yoursite.com/verify.php?id=1&value=randomstring
verify.php
PHP Code:
$id $_GET['id'];
$value $_GET['value'];
//don't forget to sanitize this data

$query "SELECT COUNT(*) FROM meta_data
WHERE meta_key = 'confirm' AND user_id = '
$id' AND meta_value = '$value';";
.
.

As I mentioned, this method allows you to store generic data which is good if you plan to make future changes.
Sounds good, thanks. And I really like the 'meta' idea, that way I can use it for lots of things.
Skeddles is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to change account details w/ email confirmation
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.17197 seconds with 12 queries