// Send account activation email to user require 'phpmailer/PHPMailerAutoload.php'; $mail = new PHPMailer; $mail->isSMTP(); $mail->Host = 'smtp.gmail.com'; $mail->Port = 587; $mail->SMTPSecure = 'tls'; $mail->SMTPAuth = true; $mail->Username = 'your_email@gmail.com'; $mail->Password = 'your_gmail_password'; $mail->setFrom('your_email@gmail.com'); $mail->addAddress($user_email); $mail->isHTML(true); $mail->Subject = 'Activate your account'; $mail->Body = 'Activate Account'; if(!$mail->send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; } else { echo 'Account activation link has been sent to your email address.'; } // Verify user account using activation code if (isset($_GET['token'])) { $activation_token = $_GET['token']; $sql = "SELECT * FROM users WHERE activation_token = '$activation_token' LIMIT 1"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { $user = mysqli_fetch_assoc($result); $user_id = $user['id']; // Update user account status $sql = "UPDATE users SET status='active' WHERE id=$user_id"; mysqli_query($conn, $sql); // Delete activation token $sql = "UPDATE users SET activation_token='' WHERE id=$user_id"; mysqli_query($conn, $sql); echo 'Your account has been activated. You can now log in.'; } }In this example, we use the PHPMailer package library to send an activation email to the user's email address. We also use a unique activation token to identify the user account and activate it. The activation link contains the activation token, which is passed as a parameter to the activation page. The database is queried to find the user account with the corresponding activation token, and the account is activated by updating the status field in the database. Finally, the activation token is deleted from the database, and the user is notified that their account has been activated.