[TUTORIAL] PHP Script for Seraph's Dominion Email Verification
Posts 1–4 of 4 · Page 1 of 1
[TUTORIAL] PHP Script for Seraph's Dominion Email Verification
For those of you that want to get the email verification system working on the Seraph's Dominion source you'll need to place the following little php script I whipped up on your website.
Create a new text file and name it verify.php. Copy and paste this code into your new verify.php file and make sure to change the database credentials to your own before uploading it to your website.
verify.php
Code:
<?php
// Verification script by Snuffleupagus
define('DB_HOST', 'LOCALHOST');
define('DB_USER', 'USERNAME');
define('DB_PASS', 'PASSWORD');
define('DB_NAME', 'rotmg');
function init_db() {
try {
$pdo = new PDO( 'mysql:host='.DB_HOST.';dbname='.DB_NAME, DB_USER, DB_PASS );
return $pdo;
} catch ( PDOException $e ) {
error_log( "Failed to connect to database: " . $e->getMessage() );
die("No database connection.");
}
}
$pdo = init_db();
if (@$_GET['email'] && @$_GET['key']) {
$q = $pdo->query("SELECT * FROM `emails` WHERE `email` = ".$pdo->quote($_GET['email'])." AND `accessKey` = ".$pdo->quote($_GET['key']) );
if (!$q) {
error_log( "Error fetching record from `emails` table: " . $e->getMessage() );
die("Database error.");
}
$row = $q->fetch();
if ($row) {
$q = $pdo->exec("UPDATE `accounts` SET verified = 1 WHERE `email` = ".$pdo->quote($row['email']));
if ($q == 1) {
echo "Account successfully verified.";
} else if ($q == 0) {
echo "Account already verified.";
}
} else {
echo "Account validation failed";
}
}
You'll also need to make some necessary adjustments in server/account/sendVerifyEmail.cs which is self explanatory.
Enjoy!
Credits
Snuffleupagus for the script.
@Kithio for the source.
@Club559 for the source.
For those of you that want to get the email verification system working on the Seraph's Dominion source you'll need to place the following little php script I whipped up on your website.
Create a new text file and name it verify.php. Copy and paste this code into your new verify.php file and make sure to change the database credentials to your own before uploading it to your website.
verify.php
Code:
<?php
// Verification script by Snuffleupagus
define('DB_HOST', 'LOCALHOST');
define('DB_USER', 'USERNAME');
define('DB_PASS', 'PASSWORD');
define('DB_NAME', 'rotmg');
function init_db() {
try {
$pdo = new PDO( 'mysql:host='.DB_HOST.';dbname='.DB_NAME, DB_USER, DB_PASS );
return $pdo;
} catch ( PDOException $e ) {
error_log( "Failed to connect to database: " . $e->getMessage() );
die("No database connection.");
}
}
$pdo = init_db();
if (@$_GET['email'] && @$_GET['key']) {
$q = $pdo->query("SELECT * FROM `emails` WHERE `email` = ".$pdo->quote($_GET['email'])." AND `accessKey` = ".$pdo->quote($_GET['key']) );
if (!$q) {
error_log( "Error fetching record from `emails` table: " . $e->getMessage() );
die("Database error.");
}
$row = $q->fetch();
if ($row) {
$q = $pdo->exec("UPDATE `accounts` SET verified = 1 WHERE `email` = ".$pdo->quote($row['email']));
if ($q == 1) {
echo "Account successfully verified.";
} else if ($q == 0) {
echo "Account already verified.";
}
} else {
echo "Account validation failed";
}
}
You'll also need to make some necessary adjustments in server/account/sendVerifyEmail.cs which is self explanatory.
Enjoy!
Credits
Snuffleupagus for the script.
@Kithio for the source.
@Club559 for the source.
This could be useful down the road. I like the fact you use the newer PHP Standards for database connections instead of the old one that most poeple use