Why the script doesn't work as it should?

Hi all. Wrote a script but it is not as it should work: here did file ads.js in which
$ad = "<script src="js/ads.js"></script>";
 echo $ad;
$adb = "ADB enabled";


Here... then do the checking, this kind of(I'm putting in the database the ip and country)
if(empty($ad)){
 $intoip = $pdo->prepare("INSERT INTO views(ip, country) VALUES(:ip, :country)");
 $intoip->bindParam(':ip', $ip);
 $intoip->bindParam(':country', $country);
$intoip->execute();
}else{
 $intoip = $pdo->prepare("INSERT INTO views(ip, country, adb) VALUES(:ip, :country, :adb)");
 $intoip->bindParam(':ip', $ip);
 $intoip->bindParam(':country', $country);
 $intoip->bindParam(':adb', $adb);
$intoip->execute();
}


In fact the script should work like this: if adblock is enabled, execute the code after the else, but if turned off then the code after the if. Checked it myself, it turned out that adblock file zablocie and dB signed up what adblock is enabled(TRUE), checked again, but with off adblock'ohms, the file works, but in the database recorded that adblock is also included, i.e. run the code after the else statement twice, why? What am I doing wrong?
June 14th 19 at 20:13
1 answer
June 14th 19 at 20:15
Solution
I told you already answered that it is necessary not on the server to do it, and on the client
I read what you wrote to me, but I will need to transfer because the data in the database, but I'm not versed in js, and especially to transfer in php - humberto.Wuckert18 commented on June 14th 19 at 20:18
Okay, will do on the client side, even did not change the value in any way. - humberto.Wuckert18 commented on June 14th 19 at 20:21
Alexander, and you, excuse me, really as interested in the literacy of obhodilis Won? Let continue the script checks on the server someone from this worse?.. - chelsea13 commented on June 14th 19 at 20:24
I'm not versed in js, and especially to transfer in php
I don't know the piano, will it be drumming Chopin ))) - lily.Kozey commented on June 14th 19 at 20:27

Find more questions by tags PHP