How do I prevent others from sending their own data to my php page?

后端 未结 5 1915
孤独总比滥情好
孤独总比滥情好 2020-12-20 04:01

Suppose I have a registration page in my website that contains a registration form:

5条回答
  •  难免孤独
    2020-12-20 04:47

    After submitting the form, the request goes to a php page. In that page you use the below code to check if its coming from your domain:

    if(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST) == "yourdomain.com") {
    
         //process the request
    } else {
    
         echo "Sorry";
    
    }
    

    EDIT: Agree. This is not secure. Just a bad hack

提交回复
热议问题