1

I have a script that gets a user's browser screen size using JavaScript and adds the variablse to MySQL with PHP.

I have a problem with my script, because the JavaScript works on user's side and PHP works on server side.

I do it like in my script example, but in MySQL adding line with all javascript code, not with user browser screen size. Please help me to solve my problem. Thank you.

P.S. Script working in "shadow".

<?php 

$width = "<script>document.write(screen.width);</script>";
$height = "<script>document.write(screen.height);</script>";
$resolution = $width.' x '.$height;

//-- Create connection
$conishua = new mysqli($sv_name, $ur_name, $multipass, $db_name);
$conishua->set_charset('utf8');

//-- Check connection
if (mysqli_connect_errno()){echo "Failed to connect to DB: " . mysqli_connect_error();}

//-- Open DB a check if exist
$base_search = $conishua->query("SELECT id FROM `db_name` LIMIT 1");

#IF DB NOT EXIST - CREATE IT AND DO A QUERY
if ($base_search === FALSE) {

    //-- Create not existed DB
    $user_ip_table = "CREATE TABLE IF NOT EXISTS `db_name` (
    `id` int(11) AUTO_INCREMENT PRIMARY KEY NOT NULL,
    `ip` tinytext NOT NULL,
    `agent` tinytext NOT NULL,
    `date` tinytext NOT NULL,
    `time` tinytext NOT NULL,
    `resolution` tinytext NOT NULL)AUTO_INCREMENT=146789 DEFAULT CHARSET=utf8;";

        //-- Do a query for new user ip if DB exist
        if ($conishua->query($user_ip_table) === TRUE && !$BOT) {

            $newUser = "INSERT INTO `db_name` (ip, agent, date, time, resolution) values ('$ip', '$agent', '$date', '$time', '$resolution')";
            $rs = $conishua->query($newUser);

        }


} ?>

In MySql output just like this <script> document.write(screen.width); </ script> instead 1388 x 768 or else.

Please help modify my script.

0 Answers0