E-Mail Varification

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Wee-Man
Forum Commoner
Posts: 45
Joined: Wed Mar 03, 2004 7:55 am
Location: Peterborough, England

E-Mail Varification

Post 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?
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

try looking up the [php_man]mail()[/php_man] function!
Wee-Man
Forum Commoner
Posts: 45
Joined: Wed Mar 03, 2004 7:55 am
Location: Peterborough, England

Post by Wee-Man »

that only sends mail to the user, :S i didnt see nothing about a varification link for the user to click
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post 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!
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post 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)
Wee-Man
Forum Commoner
Posts: 45
Joined: Wed Mar 03, 2004 7:55 am
Location: Peterborough, England

Post by Wee-Man »

ok wow ill just sit down and read that over 100 times :D,

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?
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

when you do your select statement to check if users are int he datase base just add something like "WHERE reg=1"
Wee-Man
Forum Commoner
Posts: 45
Joined: Wed Mar 03, 2004 7:55 am
Location: Peterborough, England

Post 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
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post 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!
Wee-Man
Forum Commoner
Posts: 45
Joined: Wed Mar 03, 2004 7:55 am
Location: Peterborough, England

Post 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?
Wee-Man
Forum Commoner
Posts: 45
Joined: Wed Mar 03, 2004 7:55 am
Location: Peterborough, England

Post by Wee-Man »

and it will know what $user and $pass are by the session cookies?
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post 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.
Wee-Man
Forum Commoner
Posts: 45
Joined: Wed Mar 03, 2004 7:55 am
Location: Peterborough, England

Post by Wee-Man »

ok im still flipping out, im thick on this one lol
Wee-Man
Forum Commoner
Posts: 45
Joined: Wed Mar 03, 2004 7:55 am
Location: Peterborough, England

Post by Wee-Man »

so what is the link that goes to the web page for the user to varify?
Wee-Man
Forum Commoner
Posts: 45
Joined: Wed Mar 03, 2004 7:55 am
Location: Peterborough, England

Post 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?
Post Reply