javascript - how can i know if a php file was only called from js on the client side? -
i have javascript on webpage makes call php file , passes values php file. how can know sure call php file js on webpage , not directly entering php url browsers address bar?
you'll want use check if $_server['http_x_requested_with']
xmlhttprequest
. prevent people directly typing url in browsers while allowing ajax requests.
if ( ! empty($_server['http_x_requested_with']) && $_server['http_x_requested_with'] == 'xmlhttprequest' ) { // useful }
you might want see do browsers support php's $_server['http_x_requested_with']? explanation of browsers/javascript libraries send http_x_requested_with
header.
Comments
Post a Comment