Search code examples
phpreferrer

verify entrance source in php


I have a link on the page that opens a contact form in a modal window.

How can I verify that the user clicked on the link to access the contact form, and did not go to the page directly. I don't want users or bots inadvertently browsing to that page.

Thanks in advance!


Solution

  • You can check for $_SERVER['X_HTTP_REQUESTED_WITH'] header, which will be xmlhttprequest whenever it's an ajax request