Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

My website own website login with activation not working

Hi guys, i'm making a login/registration and activation for my website, and i made the registration system, now heres how i want the system to work: You registrer your user, your information then go into a database with columns like user_firstname etc. and then i have an active column that always in the start have a 0. Then i have a column with a lot of encrypted text like 10AB241501 etc. i then made a function that would make the user column go from 0 to 1 when they pressed on the link. And then the user would get redirected to the login page and get the message "You have been activated. Please login" or something like that. But the problem is that my query for sending in that state wont work. I inspected the website but it shows nothing at all not even a FATAL ERROR in the code either. i don't know what the problem is cause i'm not getting an error really. Heres my code:

function activate_user() {

if($_SERVER['REQUEST_METHOD'] == "GET") {

    if(isset($_GET['user_email'])) {

        $email = clean($_GET['user_email']);

        $validation = clean($_GET['validation_code']);

        $sql = "SELECT user_id FROM users WHERE user_email = '".escape($_GET['user_email'])."' AND validation_code = '".escape($_GET['validation_code'])."' ";
        $result = query($sql);
        confirm($result);

        if(row_count($result) == 1) {

         $sql2 = "UPDATE users SET active = 1, validation_code = 0 WHERE user_email = '".escape($email)."' AND validation_code = '".escape($validation)."' ";
         $result2 = query($sql2);
         confirm($result2);

         set_message("<p class='bg-success'>Your Account has been activated, you can login now.</p>");

         redirect("login.php");

        }
    }

} 

}