activation email

Location of the Videos
Post Reply
devil777777
Posts: 12
Joined: Sat Aug 22, 2009 2:28 am

activation email

Post by devil777777 »

how does one go about making new users have to validate their account to make sure they are using their email (kind of like the way i had to activate this account for these boards)
User avatar
Sakar
Posts: 520
Joined: Thu Apr 23, 2009 2:59 am

Re: activation email

Post by Sakar »

Well this is how I did it. Probably not the best way but it works:

Created a BOOL field in my users table that is set to false (0) by default. Named it 'isactive'
Created an INT field in users table named 'randid'
When the user creates their account it generates a random number between 1000 and 999999999 and saves it in the 'randid' field
Send an email to the email entered during registration with a link to the activation page. example url: http://www.yourdomain.com/activateaccou ... [i]$randid[/i]
When they goto that link it gets the id from the url and checks it against the DB. If it finds a match it sets the 'isactive' field to true and removes the 'randid' of that account. If no match is found it presents an error message.

Now in the authenticate script I just check to see if 'isactive' is true or not and if it is proceed normally, otherwise tell them that their account is inactive.

Hope this helps! If you need more help feel free to ask.
devil777777
Posts: 12
Joined: Sat Aug 22, 2009 2:28 am

Re: activation email

Post by devil777777 »

thanks, something else now i get this:
;[

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\reguser.php on line 157
registration successful. You have been sent an activation key.
Click here to Login

so i have it all set up right i just need to change my php.ini or use that ini_set but i dont know what to do for either ><

heres the code incase you wanted to see for line 157 , but i know it works :P (or so you can show me where to place the ini_set thingy xD )

Code: Select all

reguser.php

146      $password=md5($password);
147      $date=round(date("U")/1000);
148      srand($date);
149      $thekey=rand(1,100000000);
150      $thekey=md5($thekey);
151
152      $SQL = "INSERT into players(playername, password, skillpts, email, validated, validkey, gold, hp, maxhp, atkskill) VALUES ('$player','$password','20','$email','0','$thekey','100','100','100','1')";
153      mysql_query($SQL) or die("could not register");
154
155
156
157      mail("$email","Activation key","Paste the URL to activate your account.  $path/activate.php?player=$player&password=$password&keynode=$thekey");
158
159       print "<center>";
160
161       print "registration successful. You have been sent an activation key.<br>";
162       print "Click here to <A href='login.php'>Login</a>";
163    }
164  }
165}
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: activation email

Post by Torniquet »

I done a walk through tutorial on how to do an advanced register page that has email activation

http://indie-resource.com/forums/viewto ... f=26&t=560

u might get a better idea how to do it if u look at the code from there
New Site Coming Soon! Stay tuned :D
devil777777
Posts: 12
Joined: Sat Aug 22, 2009 2:28 am

Re: activation email

Post by devil777777 »

cool thanks, that should definately help. I will check it out in a few.
User avatar
Noctrine
Posts: 928
Joined: Thu Apr 23, 2009 9:57 pm

Re: activation email

Post by Noctrine »

Unless you want your mail forever regulated to the spam bin, I recommend finding an existing php script / solution to do it. Creating valid email headers is both art and science
Jesse Dorsey
ProjectANI - Lead Developer Person
http://about.me/jessedorsey
Post Reply

Return to “Older Browser MMO Videos”