Email activation not working

PHPnewbie25

New Member
Messages
17
Reaction score
0
Points
1
hi so I'm working on an email activation so that users verify themselves, during the testing process the user receives the email with the link however once its clicked the page appears blank, none of my echoes are displayed stating whether it has been accepted or denied and the database has not adapted the activated column to 1. Could anyone inform me of what could be wrong I've run an error function to detect errors and nothing appears.

PHP:
<?php
error_reporting(E_ALL);
if(isset($_GET['user']) && $_GET['user'] != "" && isset($_GET['token']) && $_GET['token'] != ""){
include_once ("conninfo2.php");
$user = preg_replace('#[^0-9]#', '', $_GET['user']);
$token = preg_replace('#[^a-z0-9]#i', '', $_GET['token']);
$stmt = $db->prepare("SELECT user, token FROM activate WHERE user=:user AND token=:token LIMIT 1");
$stmt->bindValue(':user',$user,PDO::PARAM_INT);
$stmt->bindValue(':token',$token,PDO::PARAM_STR);
try{
    $stmt->execute();
    $count = $stmt->rowCount();
    if($count > 0){
        try{
            $db->beginTransaction();
            $updateSQL = $db->prepare("UPDATE login SET activated='1' WHERE usersid=:user LIMIT 1");
            $updateSQL->bindValue(':user',$user,PDO::PARAM_INT);
            $updateSQL->execute();
            $deleteSQL = $db->prepare("DELETE FROM activate WHERE user=:user AND token=:token LIMIT 1");
            $deleteSQL->bindValue(':user',$user,PDO::PARAM_INT);
            $deleteSQL->bindValue(':token',$token,PDO::PARAM_STR);
            $deleteSQL->execute();
            if(!file_exists("members/$user")){
                mkdir("members/$user", 0755);
            }
            $db->commit();
            echo "Your account has been activated! Please Login";
            $db = null;
            exit();
         
        }
        catch(PDOException $e){
            $db->rollBack();
            echo $e->getMessage();
        }
        }
        else
        {
        echo "Sorry an error has occurred please register again";
        $db = null;
        exit();
        }
    }
           catch(PDOException $e){
           echo $e->getMessage();
           $db = null;
           exit();
           }
        }
?>
 
Last edited:

caftpx10

Well-Known Member
Messages
1,534
Reaction score
114
Points
63
Try using var_dump() for the variables to look for anything odd such as "FALSE".
I would also recommend using a .htaccess trick and GET for the members page so it makes it look like a directory in the URL when it isn't, this means storing user data in the database.
 
Top