Getting the screen resolution using PHP

前端 未结 21 1882
你的背包
你的背包 2020-11-22 06:50

I need to find the screen resolution of a users screen who visits my website?

21条回答
  •  [愿得一人]
    2020-11-22 07:05

    Here is the Javascript Code: (index.php)

    
    

    Here is the PHP Code: (sqldb.php)

    $data = $_POST['screensize'];
    $pdo = new PDO('mysql:host=localhost;dbname=test', 'username', 'password');
    $statement = $pdo->prepare("UPDATE users SET screen= :screen WHERE id = $userid");
    $statement->execute(array('screen' => $data));
    

    I hope that you know how to get the $userid from the Session, and for that you need an Database with the Table called users, and an Table inside users called screen ;=) Regards KSP

提交回复
热议问题