- Home /
Email verification based registration
For my game, I want to do registration of game players. For this I was using Email address for actual player identity.
Can anybody able to give me a way how to check actual email address? so that I can ignore fake email address players. Which ever player's email address is actual reach at destination they got successful registration in game, and rest get rejection.
Please share your opinion into this. My motto is unique identity of each game players.
You could make it so the account activates/let's the player in only after they accepted a confirmation that has been sent to said email.
@iAmAwsum, can you please clarify this more? so that I can implement exactly, you want to say.
He said like:
When the user registrate it's account using e-mail, password, etc... Another e-mail will automatically be sent to YOUR e-mail. From there you can accept the e-mails you think are real and when this happens they will be Confirmed as real players. If you make it, please let me know. I would like to know how to make something like this.
Yes I am using servers so directly in communication with web developers.
Answer by money4honey · Nov 05, 2016 at 06:01 PM
you can send email with verification link via php, and use database to store information about verification
<?php
function sendEmail($from, $to, $subject, $message) {
$message = "<html>
<head><title>{$subject}</title></head>
<body>{$message}</body>
</html>";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= "From: <{$from}>" . "\r\n";
if (count($to) == 1) {
mail($to, $subject, $message, $headers);
}
elseif (count($to) > 1) {
foreach($to as $receiver) {
mail($receiver, $subject, $message, $headers);
}
}
}
function cleanInput($value = "") {
$value = trim($value);
$value = strip_tags($value);
$value = htmlspecialchars($value);
$value = addslashes($value);
return $value;
}
function validate_email() {
return filter_var($email, FILTER_VALIDATE_EMAIL) ? true : false);
}
function generatePassword($length = 8) {
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$count = mb_strlen($chars);
for ($i = 0, $result = ''; $i < $length; $i++) {
$index = rand(0, $count - 1);
$result .= mb_substr($chars, $index, 1);
}
return $result;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if ($_POST["email_verification"]) {
$email = cleanInput($_POST["email"]);
if (validate_email($email)) {
$key = generatePassword();
$link = "http://yoursite.com/handler.php?confirm_email=1&email={$email}&key={$key}";
// here you need send email & key relationship to database
sendEmail("me@mail.com", array($email), "Confirm your email", "For email confirmation <a href=\"{$link}\">click this link</a>.")
}
else {
echo "invalid email";
}
}
}
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
if ($_GET["confirm_email"]) {
$email = cleanInput($_GET["email"]);
$key = cleanInput($_GET["key"]);
if () {// if email exist in database and key is valid
// tell to db that this email pass verification
}
}
// this for checking user status from unity script
elseif ($_GET["is_verification_complete"]) {
// send request to db for user verification status
}
}
?>
@money4honey, this point I can't able to get! does fiter_var method in built provided by php ??
fiter_var is built-in php method. I think you can use it by doing post request from unity script to your server
Actually how email verification will perform into this? that I can't able to get...
ok, check it now. i skip all code that relates to db requests
Now you are in right track :)
I have one question into this, as player fill up form and record is added into server and server send email for verification. If email address is fake then verification not get completed because of wrong email address. Then how to remove this fake record from server database?
i don't know how to check that email delivered successfully, but you can use cron-script for cleaning. for instance: if user registered a week ago and not pass email confirmation, you can delete this user.
<?php
if ($argv[1] == "clean_fake_users") {
// send request to db, something like this
// $$anonymous$$ETE FRO$$anonymous$$ G$$anonymous$$_users WHERE id in (SELECT id FRO$$anonymous$$ G$$anonymous$$_users WHERE timestamp < {$week_ago_timestamp} AND verification_status = 0)
}
?>
you can run this script with cron, for instance:
php /home/yoursite/public_html/php/cron_tasks.php clean_fake_users >/dev/null 2>&1
once per day: 0 0 ***
Answer by Jip1912 · Nov 05, 2016 at 06:53 PM
You can use google play services if you are making an android game.
I want to do custom registration because I want to get other information from game players as well.
Answer by sandeepsmartest · Feb 21, 2017 at 06:07 AM
Just if in case , still if you are searching for solution, i have an alternate solution i.e., taking a mail id in which android registered may help you.As every android device will have one valid default mail id. Also , you can make use of android id aswell which is unique. Hope this may help you. Thank you. Nsks
Your answer
Follow this Question
Related Questions
Facebook log in with email and password 0 Answers
Registration script 1 Answer
After account email change, asset store still uses old email, at first 0 Answers
Unity log-in verification email code time-out 0 Answers
Why do I get a newline (\n br) while sending a simple string from php to Unity c# 1 Answer