Page 1 of 2
E-Mail Varification
Posted: Wed Mar 03, 2004 7:31 pm
by Wee-Man
Hi i have my login / register script done, but i would like a email varification on it, i would have a clue how to do this and cant seem to find help else where.
anyone have any ideas?
Posted: Wed Mar 03, 2004 7:40 pm
by Illusionist
try looking up the [php_man]mail()[/php_man] function!
Posted: Wed Mar 03, 2004 7:49 pm
by Wee-Man
that only sends mail to the user, :S i didnt see nothing about a varification link for the user to click
Posted: Wed Mar 03, 2004 7:53 pm
by Illusionist
uhh... you would put that in your email and then they clickt he link and it goes to a page you have setup and in the database whent hey first register have field like registration and have like pending or something and tehn when they visit the click it verifies their email and password and then changes the pending to registered!
Posted: Wed Mar 03, 2004 7:55 pm
by d3ad1ysp0rk
generate a random number thats stored with their username, then the URL in the body of the email would be
yoursite.com/verify.php?userid=84&code=489434
(ie. yoursite.com/verify.php?userid=$id&code=$randcode)
then on verify.php check the dbvalue for the random code (saved when the email was sent), versus the one in the URL (ie. SELECT vercode FROM table WHERE userid = $id) and if its the same, then change the account to active (say db var "active" from 0 to 1 or w/e)
Posted: Wed Mar 03, 2004 7:59 pm
by Wee-Man
ok wow ill just sit down and read that over 100 times

,
ok ok, ok, ok,
i get it to send an email using mail() with a link going to a page that changes a collum in a table like if i had "register" default is 0 when its 1 they can login, but how do i restrict them form logging in if it is 0?
Posted: Wed Mar 03, 2004 8:02 pm
by Illusionist
when you do your select statement to check if users are int he datase base just add something like "WHERE reg=1"
Posted: Wed Mar 03, 2004 8:04 pm
by Wee-Man
ok i think i get it, just im very new so this will take time and putting it into the login script i have had help with will be hard i think
Posted: Wed Mar 03, 2004 8:05 pm
by Illusionist
So if you have your SELECT statement setup so that it searches for a match in the username and password entered you can do somethign like:
"SELECT * FROM tbl_users WHERE user='$user' AND pass='$pass' AND reg='1'"
Then if that reg wasn't activated, it would be 0, and it wouldn't find a match!
Posted: Wed Mar 03, 2004 8:07 pm
by Wee-Man
yoursite.com/verify.php?userid=84&code=489434
can i break the above down and see if im right.
yoursite.com/=my site
verify.php?=page
userid=84=the users unique ID
&code=489434 = what?
Posted: Wed Mar 03, 2004 8:08 pm
by Wee-Man
and it will know what $user and $pass are by the session cookies?
Posted: Wed Mar 03, 2004 8:10 pm
by Illusionist
yeah, or by the login form.
And the code in LiLpunkSkateR's example was jsut a random number given tot hat user and added to the databse with that user and use that as a way of verification.
Posted: Wed Mar 03, 2004 8:10 pm
by Wee-Man
ok im still flipping out, im thick on this one lol
Posted: Wed Mar 03, 2004 8:12 pm
by Wee-Man
so what is the link that goes to the web page for the user to varify?
Posted: Wed Mar 03, 2004 8:14 pm
by Wee-Man
ok i have another aproach, an email is sent to the user telling them to go to a page,
on the page are 2 boxes,
one is their email wich tehy have to enter then their password,
if both match and reg=1 it goes to 0 and they are varified.
if it is 0 it tels them they are already varified, will that work?