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

The Archive Base Latest Questions

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

Thanks to a youtube tutorial from Nickfrosty on being able to create a proper

  • 0

Thanks to a youtube tutorial from Nickfrosty on being able to create a proper registration system in php, I have been able to convert his code from mysql to mysqli and was able to send an activation link by email after the user has registered.

Below is the code where it inserts the registration details in the database and sends the message and activation link to the user’s email after the user has registered.

$code = md5(rand());

$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();

$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 = "";
}

But I have an issue now. If I click on the link, it navigates the user to the activate.php page.

My question is: after the user has clicked on the activation link, how does it activate the user’s account? I need it to be able to recognize the user’s username and activation code by looking it up in the php above $message .= "$site/activate.php?user=$getuser&code=$code\n"; and then in the database I need it to update the Active column for that user from 0 to1`, so that the user is now active. Is the below statement correct:

"UPDATE Teacher SET Active='1' WHERE TeacherUsername = '$getuser'"
"SELECT * FROM Teacher WHERE TeacherUsername='$getuser' AND Active='1'"

The activate.php page simply displays a message, stating that account is activated. If user has already been activated, then I want it to display message stating user has already been 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:40:19+00:00Added an answer on June 10, 2026 at 10:40 am

    This is how I’d code the activate.php :

    Code :

    $sUser = $_GET['username'];
    $sCode = $_GET['code'];
    
    //MYPRIVATEKEY defined on a conf.php or else
    $sEncodedUser = hash_hmac('sha1', $sUser, 'MYPRIVATEKEY');
    
    if($sEncodedUser == $sUser) {
        $sQuery = "UPDATE USER SET activated=1 WHERE USERNAME = " . escape($sUser);
        //RUN $sQuery;
        echo 'Account activated !';
    } else {
        echo 'Problem when activating your account';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been watching Xcode tutorials on youtube and learning from examples online but
I want to play YouTube videos from my iPhone app. I have to tried
I'm following the video tutorial linked below from youtube to build a 3D java
I have been looking for a tutorial that shows or explains how to display
Hi and thanks for looking into this. I have a code I've been working
I have this youtube link for example: http://www.youtube.com/watch?v=3aICB2mUu2k And I need with PHP to
I am following Java Hibernate tutorial example from YouTube. Everything looks great until I
I want to create an application that support Youtube API. I use this tutorial
Thanks to the epic work of Dennis Williamson, I am now able to calculate
Thanks for reading this. I have no idea why this is throwing a NullReferenceException

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.