[Tyler & Bane release]Email

03/17/2011 07:03 RebeccaBlack#1
Registration modified to verify a person's email. Requires PHPMailer (Included)

You will need to change mail.php for your smtp server, possibly verify.php for your queries, and db.config.php for your database info. The rest is up to you :P


*Edit*
I uploaded a different Registration, this one is more of a "personal" one, which has jQuery to verify all fields are entered, and to check if the username already exists beforehand. It also has more commenting throughout the scripts to help explain, seeing as my previous didn't.

Listed below are things you will need to look for in the files.

Register.php

Verify.php

db.php

db.config.php

recaptchalib.config.php

recaptchalib.php

verifyuser.php

mail.php

To make it require email to log in to the server is up to you. If you look at the files, I used the UseQueue column. To make sure no one can login without verifying, I changed the Login Procedure (usp_Try_GameLogin_Taiwan), to include something like this:
*Note* This is NOT the full login procedure, it's merely a snippet. I am just showing you how I did made email verification a need for login. This also does not have the dupe fix, as it is just my test server.

As for the two .js files, those are for the register.php; They verify that all fields have been entered, and assist with the check for correct username.

Credits to:
Abrasive - For the registration script itself
Bane - For helping me finish
03/17/2011 07:04 Bаne#2
Nom everyone enjoy this!! :D also if all fails you will need to add 2 new colums in the user master table.

-This was a dev team release BTW.-
03/17/2011 10:36 [GM]Recover#3
thanks bane i just started this
03/17/2011 11:40 topazee#4
thanks you :)
03/17/2011 15:14 ProfNerwosol#5
Quote:
Originally Posted by [GM]Bane View Post
Nom everyone enjoy this!! :D also if all fails you will need to add 2 new colums in the user master table.
Not really. The database already has everything you need to enable email activation.
03/17/2011 17:22 Bаne#6
Quote:
Originally Posted by ProfNerwosol View Post
Not really. The database already has everything you need to enable email activation.
Mech realy? We added a whole two new column for this lol..
03/18/2011 11:02 kissangel#7
after configured everything i found out that you can still login even without verification through your email
03/18/2011 11:56 RebeccaBlack#8
That is true. That is why I said the rest is up to you.

You need to change the queries a bit, as well as change your login procedure.

Changing the queries in them, you need to have the "verify" half of verify.php to let's say... update Users_Master and change UseQueue to 1, whereas the registering half changes it to 0.

Then alter your login procedure, if UseQueue is 0 Set Status=-2 else Set Status=0
03/18/2011 18:34 xdye#9
i get this when try to register an account :/
Quote:
Warning: mssql_query() [function.mssql-query]: message: Cannot insert the value NULL into column 'UserUID', table 'PS_UserData.dbo.Users_Master'; column does not allow nulls. INSERT fails. (severity 16) in H:\xampp\htdocs\Nova pasta\verify.php on line 67

Warning: mssql_query() [function.mssql-query]: Query failed in H:\xampp\htdocs\Nova pasta\verify.php on line 67

Warning: mssql_query() [function.mssql-query]: message: Cannot insert the value NULL into column 'UserUID', table 'PS_UserData.dbo.Users_Detail'; column does not allow nulls. INSERT fails. (severity 16) in H:\xampp\htdocs\Nova pasta\verify.php on line 72

Warning: mssql_query() [function.mssql-query]: Query failed in H:\xampp\htdocs\Nova pasta\verify.php on line 72

Fatal error: Uncaught exception 'phpmailerException' with message 'Invalid address: REPLY EMAIL' in H:\xampp\htdocs\Nova pasta\PHPMailer\class.phpmailer.php:462 Stack trace: #0 H:\xampp\htdocs\Nova pasta\PHPMailer\class.phpmailer.php(440): PHPMailer->AddAnAddress('ReplyTo', 'REPLY EMAIL', 'YOUR NAME') #1 H:\xampp\htdocs\Nova pasta\mail.php(15): PHPMailer->AddReplyTo('REPLY EMAIL', 'YOUR NAME') #2 H:\xampp\htdocs\Nova pasta\verify.php(78): require('H:\xampp\htdocs...') #3 {main} thrown in H:\xampp\htdocs\Nova pasta\PHPMailer\class.phpmailer.php on line 462
03/18/2011 19:04 abrasive#10
Quote:
Originally Posted by xdye View Post
i get this when try to register an account :/
Code:
Cannot insert the value NULL into column 'UserUID'
The solution for that error is the same as in this post (post #67): [Only registered and activated users can see links. Click Here To Register...]
03/18/2011 19:09 RebeccaBlack#11
Quote:
Originally Posted by xdye View Post
i get this when try to register an account :/
Code:
Fatal error: Uncaught exception 'phpmailerException' with message 'Invalid address: REPLY EMAIL' in H:\xampp\htdocs\Nova pasta\PHPMailer\class.phpmailer.php:462 Stack trace: #0 H:\xampp\htdocs\Nova pasta\PHPMailer\class.phpmailer.php(440): PHPMailer->AddAnAddress('ReplyTo', 'REPLY EMAIL', 'YOUR NAME') #1 H:\xampp\htdocs\Nova pasta\mail.php(15): PHPMailer->AddReplyTo('REPLY EMAIL', 'YOUR NAME') #2 H:\xampp\htdocs\Nova pasta\verify.php(78): require('H:\xampp\htdocs...') #3 {main} thrown in H:\xampp\htdocs\Nova pasta\PHPMailer\class.phpmailer.php on line 462

You didn't edit mail.php to your STMP server.
03/18/2011 20:07 kissangel#12
Quote:
Originally Posted by tnelis View Post
That is true. That is why I said the rest is up to you.

You need to change the queries a bit, as well as change your login procedure.

Changing the queries in them, you need to have the "verify" half of verify.php to let's say... update Users_Master and change UseQueue to 1, whereas the registering half changes it to 0.

Then alter your login procedure, if UseQueue is 0 Set Status=-2 else Set Status=0
that's kindda similar to what i did i changed the default status when register withtout verify = -1
Quote:
$sql = "INSERT INTO PS_UserData.dbo.Users_Master
(UserUID,UserID,Pw,JoinDate,Admin,AdminLevel,UseQu eue,Status,Leave,LeaveDate,UserType,Point,UserIp)
VALUES ('{$UserUID}','{$username}','{$password}',GETDATE( ),0,0,0,-1,0,GETDATE(),'N',0,'{$user_ip}')";
btw the script was missing itemUID Newsletter and SMS collum, because those collum cant be leave NULL
Quote:
$usde = "INSERT INTO PS_UserData.dbo.Users_Detail
(UserUID,UserID, PwAnswer, PwQuestion, Email, EmailAuthKey, EmailAuth, AdultAuth, NewsLetter, SMS)
VALUES ('{$UserUID}','{$username}','{$Answer}','{$Questio n}','{$Email}','{$activationKey}',0,0,0,0)";
at the end after verify just add
Quote:
$sql="UPDATE Users_Detail SET EmailAuthKey='Verified', EmailAuth=1 WHERE (UserID = '$row[UserID]')
Update Users_Master SET Status = 0 Where (UserID = '$row[UserID]')";
PS:/ on $activationKey you only need 1 mt_rand();
otherwise it will redirect you to a blank page
BTW is this script safe from SQL injection?
03/19/2011 00:06 -III-#13
Quote:
Originally Posted by kissangel View Post
that's kindda similar to what i did i changed the default status when register withtout verify = -1

btw the script was missing itemUID Newsletter and SMS collum, because those collum cant be leave NULL

at the end after verify just add
PS:/ on $activationKey you only need 1 mt_rand();
otherwise it will redirect you to a blank page
BTW is this script safe from SQL injection?
If it is based off of Abrasive's script, yes, it has the escape strings and such for the injection protection.

As per the OP, I haven't checked it out, as I see it as an added and unnecessary step for account creation (provided you are already using a form of spam protection). However, if it is also applied for password changes, this becomes far more useful.

Thank you for the release. I am sure many will find it very useful.

-III-
03/19/2011 09:21 RebeccaBlack#14
Quote:
Originally Posted by kissangel View Post
btw the script was missing itemUID Newsletter and SMS collum, because those collum cant be leave NULL

at the end after verify just add
PS:/ on $activationKey you only need 1 mt_rand();
otherwise it will redirect you to a blank page
BTW is this script safe from SQL injection?

I did not account for the original tables at the time. My database tables are slightly editted.

I have erased all unnecessary columns in both tables, so I did not check if the original needed certain tables. As for the activationkey, I changed the column length to varchar(MAX)
03/24/2011 16:31 RebeccaBlack#15
Updated the OP a bit. Tried to add clearer instructions / better files.

If I ever finish the password change to require email, I'll release it as well.