'Integration Google Analytics Code - Store and Get from database using PHP

I'm currently having trouble registering Google Analytics code in the database. The error I get is 403. The hosting I use is Namecheap. I read a couple of posts on the StackOverflow site but none helped me. How can I solve the problem without changing or canceling the security measures that Namecheap has? If this problem requires encryption, I need to display the same code so we need to display that code using decryption maybe. Any advice??

Code for registering new Tracking Code:

<?php
    if(isset($_POST['submit'])) {        
        $name = $_POST['name'];
        $code = htmlspecialchars($_POST['code']);
            
        if(empty($_POST['name']) || empty(htmlspecialchars($_POST['code']))) {
            $error = "All fields are required!"; 
        } else {
            $name = SampleInput($_POST['name']);
            if (!preg_match('/^[a-zA-Z0-9\s]+$/', $name)) {
                $error = "Only letters and white space allowed";
            }
        }

        $sql = "INSERT INTO analytics(name, code, date) VALUES(:name, :code, NOW())";
        $query = $dbh->prepare($sql);
        $query->bindParam(':name', $name, PDO::PARAM_STR);
        $query->bindParam(':code', $code, PDO::PARAM_STR);
        $query->execute();
        $msg = "Well done!";
    }
?>

Note: SampleInput is a small function for preventing inserting special chars into the database.

php


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source