After a user has registered, I send an email verification link to the email used for verification. When the user clicks on the link, I have a php api that validates the code and updates the DB. Upto this its working fine. Once that is done successfully, I want to display a message saying email is verified and provide the link for login. I am stuck here.
My echo display as it is with the html tag. I am new to PHP and unable to proceed. Please help.
<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: POST");
header("Access-Control-Max-Age: 3600");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
include_once '../config/database.php';
include_once '../class/users.php';
require_once('../config/constants.php');
$database = new Database();
$db = $database->getConnection();
$item = new User($db);
$item->hash = isset($_GET['ticket']) ? $_GET['ticket'] : die();
$encryptedMessage = isset($_GET['code']) ? $_GET['code'] : die();
$decryptedMessage = openssl_decrypt($encryptedMessage, ENCRYPT_ALGO, SALT);
$item->email = $decryptedMessage;
$item->verifyEmail();
if($item->user_id != null){
$item->updateEmailVerified($item->user_id);
echo "<p style='color:red;'>" . "Hello Word" . "</p>"; // --- Displays as it is ---
}
?>

header("Content-Type: application/json; charset=UTF-8");Why?Content-Type: application/json;, so this page cannot be HTML.