javascript - How to Redirect a user if they manually refresh your webpage via f5 or browser? -
i have lots of buttons on webpage, when button clicked refreshs page need happen increase click counter, there way redirect user page if decide refresh after clicked button, if manually hit f5 or browser refresh redirected? otherwise happens every manual refresh click counter keeps counting? in php or javascript i've looked around , apparently impossible?
in javascript can prevent f5 refreshing keydown event , event.preventdefault(), i'm pretty sure can't prevent user clicking refresh button.
but both of irrelevant because hacker can send http request, increase counter.
you want have php code checks user's ip , increases counter once per ip address.
to read user's ip address in php, use $_server['remote_addr']
you store counter data database table, example 3 columns:
table name: counters
table fields:
counter_id - int unsigned auto-increment(ai) ip_address - varchar(45) hit_count - int unsigned
then run sql queries php, check if counter has been increased ip address, or increase counter.
Comments
Post a Comment