Mike Turley
Mike Turley

Reputation: 1170

How do I identify where the POST data sent to a PHP script came from?

I have a ton of data collection forms on my website, and I wrote a PHP script to handle all the data. All the forms have that one script as their action, and POST as the method. The handler emails a copy of the data to me, and I'd like for the emails I get to contain the URL of the form where they originated. Is there any way in PHP to get the url of the form which was submitted to the script? Or do I have to add an extra hidden field in every form with its URL?

Upvotes: 0

Views: 582

Answers (2)

Fenton
Fenton

Reputation: 250822

If you want to ensure that posts only arrive from your own form, you could put a one-time token on the form in a hidden field to validate.

Upvotes: 2

zaf
zaf

Reputation: 23244

Send the following variable in the email as well:

$_SERVER['HTTP_REFERER'] 

Upvotes: 3

Related Questions