php - Prevent direct access to action form -
this question has answer here:
i have form.php wich action call sql.php file like:
sql.php
if ($_request['action'] == "add") { } if ($_request['action'] == "edit") { } i'm prevent direct access, because user can call browser url: http://sql.php?action=add 1 way check if submit. seem work well.
if( isset($_post['submit']) && ($_post['submit'] == "submit") ) { echo "direct access not allowed"; } there better alternatives?
use $_server['http_referer'] array detect if accessing page directly typing in browser, or comming 1 of pages, use of links page.
so, basically.
if($_server['http_referer'] == 'about.php'){ //let user } so, $_server['http_referer'] global stores information of pages visit, , if place echo code, in page, tell page comming from. meaning, if typed page , access it, give 0/false value.
so, can use detect if directly typing page or comming 1 of pages.
as others have indicated already, using tokens, , sessions better idea since method can manipulated. so, recommend google them out
Comments
Post a Comment