Jump to content

Email Activation Link generating error


Recommended Posts

**Sorry if this is in the wrong topic, couldn't figure out where to put it**

So, when registering on my UCP, the player is sent an email activation link to their email address containing a "tokenid" that will allow the system to activate their account. They cannot use the UCP nor play in the server until their account is activated. Well I have went through every single one of my files, yet, I am still running into the same issue. The issue is that after the user clicks the link obtained in their email, they are redirected back to my site, where it is suppose to activate their account. Instead, they get the following error message, "Opps, sorry. We couldn't activate your account '********'.

It looked like the link is expired or invalid. Please click here to generate another activation email."

I have check the .php that is suppose to handle the activation, even removed the entire previous line from the file. However, somehow, it is still generating this error. I have included a copy of my .php code below to analyze. Thanks for any help given.

<?php

include("header.php");

?>

Account Activation

<?php if (!isset($_GET['userid']) or ! isset($_GET['token']))

?>

{

Prove you're human:

return false;">

captcha.php

<?php

?>

}

else

{

require_once './classes/mysql/Database.class.php';

$db = new Database("MTA");

$db->connect();

$account = $db->query_first("SELECT id, username, activated FROM accounts WHERE id='" . $db->escape($_GET['userid']) . "' ");

if ($account and $account['id'] and is_numeric($account['id']))

{

$token = $db->query_first("SELECT * FROM tokens WHERE userid='" . $db->escape($_GET['userid']) . "' AND token='" . $db->escape($_GET['token']) . "'");

if ($token and $token['id'] and is_numeric($token['id']))

{

$update = array();

$update['activated'] = 1;

if ($db->query_update("accounts", $update, "id='" . $token['userid'] . "'") and $db->query("DELETE FROM tokens WHERE id='" . $token['id'] . "'"))

{

echo "

Your account '" . $account['username'] . "' has been sucessfully activated!

";

}

else

{

echo "

Opps, sorry. We couldn't activate your account '" . $account['username'] . "'."

. "

Please try again later.

";

}

}

}

else

{

echo "

Opps, sorry we're unable to process your request.

"

. "

The account you're trying to activate does not exist.

";

}

$db->close();

}

?>

<?php

include("sub.php");

include("footer.php");

?>

Link to comment

To be honest, you need to indent that; it'll help a lot!

This is how it looks indented:

<?php 
    include("header.php"); 
?> 
<link href="css/login-form.css" type="text/css" rel="stylesheet" /> 
<div id="main-wrapper"> 
    <div id="lib_top"> 
        <center><h2>Account Activation</h2></center> 
        <?php if (!isset($_GET['userid']) or ! isset($_GET['token'])){ //<- Left this outside 
        ?> 
         
        <form id="register_form" onsubmit="ajax_resend_activation_email(); return false;" method="post" action="" onkeypress="resetError();"> 
        <br> 
        <table border=0 align="center" class="login-form" cellpadding="2"> 
            <tr> 
                <td style="text-align: center;"> 
                    <input type="text" id="reg_username" placeholder="Enter Username" maxlength="30" value="<?php echo $_GET['username']; ?>" required/> 
                    <div> 
                        <br><b>Prove you're human:</b><br> 
                        <a href="" onclick="ajax_reload_captcha(); return false;"><div id="img_captcha"><img src="captcha/captcha.php" /></div></a> 
                        <input type="text" id="reg_captcha" placeholder="Enter the text above" maxlength="5" required style="width: 146px;" /> 
                    </div> 
                    <input type="submit" id="submit_reg" value="Activate" style="margin-top: 20px; "/> 
                </td> 
                <tr> 
                    <td> 
                        <div id="error_reg" style="padding-top: 10px; color:red;font-style: italic;font-size: 11px;"></div> 
                    </td> 
                </tr> 
                <tr> 
                    <td align="center" > 
                        <div id="reg_status"></div> 
                    </td> 
                </tr> 
            </table> 
        </form> 
         
        <?php 
            }else{ 
                require_once './classes/mysql/Database.class.php'; 
                $db = new Database("MTA"); 
                $db->connect(); 
                $account = $db->query_first("SELECT id, username, activated FROM accounts WHERE id='" . $db->escape($_GET['userid']) . "' "); 
                if ($account and $account['id'] and is_numeric($account['id'])){ 
                    $token = $db->query_first("SELECT * FROM tokens WHERE userid='" . $db->escape($_GET['userid']) . "' AND token='" . $db->escape($_GET['token']) . "'"); 
                    if ($token and $token['id'] and is_numeric($token['id'])){ 
                        $update = array(); 
                        $update['activated'] = 1; 
                        if ($db->query_update("accounts", $update, "id='" . $token['userid'] . "'") and $db->query("DELETE FROM tokens WHERE id='" . $token['id'] . "'")){ 
                            echo "<p>Your account '" . $account['username'] . "' has been sucessfully activated!</p>"; 
                        }else{ 
                            echo "<p>Opps, sorry. We couldn't activate your account '" . $account['username'] . "'." 
                                . "<p>Please try again later.</p>"; 
                        } 
                    } 
                }else{ 
                    echo "<p>Opps, sorry we're unable to process your request.</p>" 
                        . "<p>The account you're trying to activate does not exist.</p>"; 
                } 
                $db->close(); 
            } 
        ?> 
    </div> 
    <div id="lib_mid" ></div> 
    <div id="lib_bot"></div> 
</div> 
<div class="content_wrap"> 
    <div class="text_holder"> 
        <div class="features_box"></div>     
  
        <?php 
            include("sub.php"); 
            include("footer.php"); 
        ?> 
<script type="text/javascript" src="js/ajax_register.js"/></script> 

Try this:

<?php 
    include("header.php"); 
?> 
<link href="css/login-form.css" type="text/css" rel="stylesheet" /> 
<div id="main-wrapper"> 
    <div id="lib_top"> 
        <center><h2>Account Activation</h2></center> 
        <?php if(!isset($_GET['userid']) or !isset($_GET['token'])){ ?> 
         
        <form id="register_form" onsubmit="ajax_resend_activation_email(); return false;" method="post" action="" onkeypress="resetError();"> 
            <br> 
            <table border=0 align="center" class="login-form" cellpadding="2"> 
                <tr> 
                    <td style="text-align: center;"> 
                        <input type="text" id="reg_username" placeholder="Enter Username" maxlength="30" value="<?php echo $_GET['username']; ?>" required> 
                        <div> 
                            <br><b>Prove you're human:</b><br> 
                            <a href="" onclick="ajax_reload_captcha(); return false;"><div id="img_captcha"><img src="captcha/captcha.php" /></div></a> 
                            <input type="text" id="reg_captcha" placeholder="Enter the text above" maxlength="5" required style="width: 146px;" /> 
                        </div> 
                        <input type="submit" id="submit_reg" value="Activate" style="margin-top: 20px; "/> 
                    </td> 
                </tr> 
                <tr> 
                    <td> 
                        <div id="error_reg" style="padding-top: 10px; color:red;font-style: italic;font-size: 11px;"></div> 
                    </td> 
                </tr> 
                <tr> 
                    <td align="center" > 
                        <div id="reg_status"></div> 
                    </td> 
                </tr> 
            </table> 
        </form> 
         
        <?php 
        }else{ 
            require_once './classes/mysql/Database.class.php'; 
            $db = new Database("MTA"); 
            $db->connect(); 
            $account = $db->query_first("SELECT id, username, activated FROM accounts WHERE id={$db->escape($_GET['userid'])}"); 
            if($account and $account['id'] and is_numeric($account['id'])){ 
                $token = $db->query_first("SELECT * FROM tokens WHERE userid={$db->escape($_GET['userid'])} AND token='{$db->escape($_GET['token'])}'"); 
                if ($token and $token['id'] and is_numeric($token['id'])){ 
                    $update = array(); 
                    $update['activated'] = 1; 
                    if ($db->query_update("accounts", $update, "id={$token['userid']}") and $db->query("DELETE FROM tokens WHERE id={$token['id']}")){ 
                        echo "<p>Your account '{$account['username']}' has been sucessfully activated!</p>"; 
                    }else{ 
                        echo "<p>Opps, sorry. We couldn't activate your account '{$account['username']}' \n<p>Please try again later.</p>"; 
                    } 
                } 
            }else{ 
                echo "<p>Opps, sorry we're unable to process your request.</p>\n<p>The account you're trying to activate does not exist.</p>" 
            } 
            $db->close(); 
        } 
        ?> 
    </div> 
    <div id="lib_mid" ></div> 
    <div id="lib_bot"></div> 
</div> 
<div class="content_wrap"> 
    <div class="text_holder"> 
        <div class="features_box"></div>     
  
        <?php 
            include("sub.php"); 
            include("footer.php"); 
        ?> 
<script type="text/javascript" src="js/ajax_register.js"/></script> 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...