I just finished reworking this registration that I had made awhile back when I was first learning PHP. I cleaned up a lot of it, and made it overall more efficient, though probably not as efficient as most people on here could do.
To use this, add it to your web server, and navigate to register.php. You must first add a table to your database, and edit config.php to add your SMTP User/Pass. As of now, I currently use PHPMailer, and have it configured to use gmail. You can edit this if you wish.
You must edit these variables in config.php:
PHP Code:
// Database configuration parameters
$db_host = "127.0.0.1"; //Your database host
$db_user = "Shaiya"; //Your database username
$db_pass = "Shaiya123"; //Your database password
//Configuration for email (Configured for gmail currently)
$smtp_user = ""; //Your gmail email | ex.
$smtp_pass = "yourpassword"; //Your gmail password
$reply_to_email = "your reply to email"; //Email players can reply to
$reply_to_name = "your name/server's name"; //Can be your server's name
PHP Code:
USE [PS_UserData]
GO
/****** Object: Table [dbo].[User_Verification] Script Date: 01/24/2012 13:40:58 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[User_Verification](
[UserID] [varchar](18) NOT NULL,
[VerifyKey] [varchar](max) NOT NULL,
[RegisterDate] [datetime] NOT NULL CONSTRAINT [DF_User_Verification_RegisterDate] DEFAULT (getdate()),
[VerifiedDate] [datetime] NULL,
[isVerified] [bit] NOT NULL CONSTRAINT [DF_User_Verification_isVerified] DEFAULT ((0))
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
I hope you enjoy this script, and it all works well for you. I've tested it and it works. What it does, is register the user with a status of -5 (one of the various banned status'), then adds the UserID/VerifyKey to the table you insert into your database. Once the user goes to his email, and clicks the link, it checks if the key exists, and hasn't been used (so the same key can't be used twice for the same user, so the user can't use it to unban his account if he's naughty). If the key is found, it'll show the key as verified in the new table and set the user as a normal user.
If you find any bugs, or have any comments, I'll be glad to know.