Am actually building a login and register system but having these internal error in the email activation part, when am trying to change the active table to 1, if users email and email_code matches.

the activate.php code :

<?php

} else if (isset($_GET['email'], $_GET['activation']) === true) {

    $email      = trim($_GET['email']);
    $email_code = trim($_GET['activation']);

    if (email_exists($email) == false) {
        $errors[] = 'Ooops, We counldn\'t find that email address';

    } else if (activate($email, $email_code) == false) {
        $errors[] = 'Ooops, We had problem activating your account';

    }

    if (empty($errors) == false){
        echo output_errors($errors) . '<br><br>'; 
    } else {
        header('Location : activate.php?success');
        exit();
    }

} else {

    header('Location: index.php');
    exit();
}

?>

The activate($email, $email_code) function :

function activate($email, $email_code) {
    global $connection;

    $email      = $email;
    $email_code = $email_code;
    $active     = 0;
    $new_update_active = 1;

    $stmt       = $connection -> prepare('SELECT id FROM users WHERE email = ? AND email_code = ? AND active = ?');

    $stmt -> bind_param('ssi', $email, $email_code, $active);
    $stmt -> execute();
    $stmt -> store_result();
    $stmt -> fetch();

    if ($stmt -> num_rows() == 1) {

        $update_active = $connection -> prepare('UPDATE users SET active = ? WHERE email = ?');
        $update_active -> bind_param('is', $new_update_active, $email);
        return true;

    } else {
        return false;
    }

}

The error: The error image!!

The code is seems correct and am only having these intenal serval when it comes to the part that the email and email_code matches and to change the active table to 1 in the database.

1 Answers

1
Community On Best Solutions

I later spot the error and i just change the

header('Location : activate.php?success');

to

header('Location: activate.php?success');