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 8440617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:20:18+00:00 2026-06-10T08:20:18+00:00

I am trying to create an activation page so the when the user clicks

  • 0

I am trying to create an activation page so the when the user clicks on their activation link, it will navigate the user to the activate.php page and display a message stating wether the account is activated or not.

The problem I have is that it keeps displaying the message “The Code and Username doesn’t match! Account is not Activated.” It does not display the successful message “Account is Activated” at all, even though the activation link has been clicked on.

Also the “Active” column in the database should change to “1” if the correct username and code has been identified, but it still keeps displaying “0”, meaning account is still inactive.

What my question is that why isn’t it recognising that the username and activation code is correct?

Below is the registration.php script where it inserts the user’s registration details and sends the activation link by email:

$teacherpassword = md5(md5("j3j".$teacherpassword."D2n"));  
$code = md5(rand(1,9));

$insertsql = "
INSERT INTO Teacher
(TeacherForename, TeacherSurname, TeacherEmail, TeacherAlias, TeacherUsername, TeacherPassword, Code)
VALUES
(?, ?, ?, ?, ?, ?, ?)
";
if (!$insert = $mysqli->prepare($insertsql)) {
// Handle errors with prepare operation here
}                                           

$insert->bind_param("sssssss", $getfirstname, $getsurname,
$getemail, $getid, $getuser,
$teacherpassword, $code);

$insert->execute();

if ($insert->errno) {
// Handle query error here
}

$insert->close();

    $getuser = $_POST['user'];
    $code = md5(rand(1,9));

    $site = "http://helios.hud.ac.uk/......../Mobile_app";
    $webmaster = "Mayur Patel <.......@hud.ac.uk>";
    $headers = "From: $webmaster";
    $subject = "Activate Your Account";
    $message = "Thanks for Registering. Click the link below to Acivate your Account. \n";
    $message .= "$site/activate.php?user=$getuser&code=$code\n";
    $message .= "You must Activate your Account to Login";

    if(mail($getemail, $subject, $message, $headers)){
    $errormsg = "You have been Registered. You must Activate your Account from the Activation Link sent to <b>$getemail</b>";
    $getfirstname = "";
    $getsurname = "";
    $getid = "";
    $getuser = "";
    $getemail = "";
    }

Below is the activate.php page where it checks the activation link and performs the mysqli operations and display the messages:

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


    // 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')
    {

   $updatesql = "UPDATE Teacher SET Active = ? WHERE TeacherUsername = ? AND Code = ?";                                         
    $update = $mysqli->prepare($updatesql);
    $update->bind_param("iss", 1, $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.";
    }

        ?>

I just want it to be able to activate the account when the link has been clicked for the first time.

  • 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-10T08:20:20+00:00Added an answer on June 10, 2026 at 8:20 am

    Got it, the error is here:

    $update->bind_param(“iss”, 1, $user_to_be_activated, $code_to_be_matched);

    simply it doesnt pass 1 and im not sure why it doesnt show you an error.

    so you can just put that number 1 into a variable and than use it in your sql code like this:

    so whole 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')
        {
    
       $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() or die(mysql_error());
            $update->close();
    
            echo "Account is Activated";
        }
        else
        {
            echo "The Code and Username doesn't match! Account is not Activated.";
        }
    

    You can test here:

    http://design05.comuf.com/avtivate.php

    with following details:

    user: master

    code: bbb111

    http://design05.comuf.com/avtivate.php?user=master&code=bbb111

    user:admin

    code: abc123

    http://design05.comuf.com/avtivate.php?user=admin&code=abc123

    and of course try some wrong ones.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an account register page with CakePHP 2.0 where user needs
Rails 2.3.11 I'm trying to send an activation-style email whenever a user registers. The
I'm trying to create a custom User Control with the following: var panel =
I am trying to create a generic factory-pattern-like mechanism. The factory will be like:
I'm trying to create a way of deploying a set of tools (which are
I am trying to create two IPC channels IpcChannel ipcChannel = new IpcChannel(DroolsClient); ChannelServices.RegisterChannel(ipcChannel,
I'm trying to create a standard osgi bundle under Eclipse Helios. To do so,
I'm relatively new to PHP and I'm trying to write my own plugin. Upon
I'm trying to create an instance of HttpPostedFile with var obj2 = Activator.CreateInstance( typeof(HttpPostedFile),
I'm trying to create a class from an assembly known only at runtime. Having

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.