How to save form data only if it comes from a particular site?

3

Hello, I have a form that is being used in another site and saving in my database, through a php action that is on my server. But I would just like to save the data if the form comes from the domain of this site. How can I do it?

    
asked by anonymous 16.12.2016 / 20:29

1 answer

0

You can check the sender domain like this:

$_SERVER["HTTP_REFERER"]; // http://www.exemplo....

But I have to warn that this is an editable parameter in the request, it can be 'forged':

if($_SERVER["HTTP_REFERER"] != 'url autorizado') {
    echo 'URL inválido';
    die();
}
    
16.12.2016 / 20:37