Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8446769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:00:33+00:00 2026-06-10T10:00:33+00:00

I am doing a piece of programming coursework for my A-Level and I am

  • 0

I am doing a piece of programming coursework for my A-Level and I am stuck on a problem. I hope one of you guys can help me.

I am setting up a member sytem, at the moment I am on the email activation stage. Using php and mysqli coding with a connected database, I have been able to set the email activation link to work so that when the user clicks on the activation link, it activates the user’s account by setting the “Active” database field from ‘0’ to ‘1’.

The only problem I have is that if the user clicks on the activation link again in the email, as the user is already active, I want it to display the message “This Account has already been Activated”;. This is so the user cannot activate the account again.

But I cannot get it to display this message. It keeps displaying the message “Account is Activated” even though the user has already activated the account. Does anyone know what I am doing wrong?

Below is my code:

<?php
$user_to_be_activated  =   $_GET['user'];
$code_to_be_matched   =   $_GET['code'];
$code_activated = 1;

// don't use $mysqli->prepare here
$query = "SELECT TeacherUsername, Active, Code FROM Teacher WHERE TeacherUsername = ? AND Code = ? ";
// prepare query
$stmt=$mysqli->prepare($query);
// You only need to call bind_param once
$stmt->bind_param("ss",$user_to_be_activated, $code_to_be_matched);
// execute query
$stmt->execute(); 
// get result and assign variables (prefix with db)
$stmt->bind_result($dbTeacherUsername, $dbActive, $dbCode);
//get number of rows
$stmt->store_result();
$counting = $stmt->num_rows();

if($counting == '1')
{

    if($dbActive == '1')
    {
        echo "This Account has already been Activated";
    }
    else{

    $updatesql = "UPDATE Teacher SET Active = ? WHERE TeacherUsername = ? AND Code = ?";                                            
    $update = $mysqli->prepare($updatesql);
    $update->bind_param("sss", $code_activated, $user_to_be_activated, $code_to_be_matched);
    $update->execute();
    $update->close();

    echo "Account is Activated";
}
}
else
{
    echo "The Code and Username doesn't match! Account is not Activated.";
}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T10:00:35+00:00Added an answer on June 10, 2026 at 10:00 am
    <?
    $stmt->store_result();
    $counting = $stmt->num_rows();
    
    if($counting == '1')
    {
        $stmt->fetch(); //added fetch here
        if($dbActive == '1')
        {
            echo "This Account has already been Activated";
        }
        else{
    
        $updatesql = "UPDATE Teacher SET Active = ? WHERE TeacherUsername = ? AND Code = ?";                                            
        $update = $mysqli->prepare($updatesql);
        $update->bind_param("sss", $code_activated, $user_to_be_activated, $code_to_be_matched);
        $update->execute();
        $update->close();
    
        echo "Account is Activated";
    }
    }
    else
    {
        echo "The Code and Username doesn't match! Account is not Activated.";
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing a piece of coursework in Java using BlueJ. We need to
I'm doing a security audit on my friend's website. One piece of functionality is
While doing some JavaScript performance tests I came up with the following piece of
Currently I am doing the profiling to a piece of code. During the profiling,
I'm doing a pattern match in a piece of code that works fine in
I am doing image Read/Copy operations in WPF application. Please look at following piece
Doing the below will reproduce my problem: New WPF Project Add ListView Name the
I am a beginner in programming. I have a large piece of code. I
I'll be as direct as I can concerning this problem, because there must be
I am doing some refactoring on a piece of code to transform all blocking

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.