jeudi 5 novembre 2020

How to use the Javascript in if statement of PHP

I make a voting website where the user vote. I used to store the user's IP address in database and then match it. But there is a problem that the user can vote multiples times by using VPN. So, i used localstorage to identify user but i don't understand how to write it. Basically i am doing this in PHP


    if("<script type='text/javascript'>document.write(Number(localStorage.getItem('name')))</script>"=='NaN')
    {
        echo "<script type='text/javascript'>alert('already visited')</script>";
    }else
    
    {
        
        echo "<script type='text/javascript'>localStorage.setItem('name','shubhamjr');
        </script>";
        echo "<script type='text/javascript'>alert('Thanks for voting')</script>";
    
    }

?>```



Aucun commentaire:

Enregistrer un commentaire