php - Verify Email and Update MySQL DB Column -
need in creating verify.php / confirm.php site after registration. email being sent email of user confirmation link. need link work this:
when link clicked, user directed our site , echo simple message , update column in our database state user verified being unverified user.
thanks in advance!
i go this:
- have users table atleast following columns: username (varchar), vrified (bool) , token(varchar).
- when user registers verified column 0 (unverified) , generate random token , insert other info solicit. won't go on how lots of tutorials on internet on how generate random token.
- after you're done inserting new user db, need send email confimation link, link have email , token of user. example:
www.mysite.com/verify.php?email=users_email&token=generated_token
. - after email has been sent, on
verify.php
need check if user exists in db , update user.
example queries:
<?php $checkuserexists = "select count(username) users email = users_email"; //this should return 1 if user exists. $updateuser = "update users set verified = 1 email = users_email , token = generated_token"; //update user if exists. ?>
- if user doesn't exist or token isn't correct, can send error message. else show user has updated correctly.
hope kinda helped out on how approach this. please write own code or post have tried, said in comments, more willing out won't work have do.
Comments
Post a Comment