php - Determining the Source of $_POST -


Is there an easy way to find out the source of a post variable in PHP?

Example.com/formone.php on the form < Form method = "post" action = "test.php" & gt; & Lt; Input name = "myusername" type = "text" & gt; & Lt; Input name = "mypassword" type = "password" & gt; & Lt; Input type = "submit" & gt; & Lt; / Form & gt;

Form on example.com/formtwo.php
  & lt; Form method = "post" action = "test.php" & gt; & Lt; Input name = "myusername" type = "text" & gt; & Lt; Input name = "mypassword" type = "password" & gt; & Lt; Input type = "submit" & gt; & Lt; / Form & gt;   

I understand that I can use hidden input, but I was wondering if there was any method to test the source of the post in PHP.

When you can potentially use the HTTP_REFERER server variable, your best bet is to hide the hidden area Have to use.

To submit another option, you have to switch input to button . In this way, you can pass a value with it, keep the button's label, and test it for your test.php page below: < Pre> & lt; Button name = "submit" type = "submit" value = "form1" & gt; Submit & lt; / Button & gt;

In your PHP file, you will again check:

  if ($ _POST ['submit'] == "form1") //    

Comments