Jump to content

source of form submit


cody7

Recommended Posts

Hi

 

What is the best way to detect the URL where the form has been submitted, here’s an example

 

"www.domain.com/page1.php" has a form that will be submitted to "www.domain.com/page2.php". I need to be sure that all variables that will be submitted to page2.php are from page1.php of the same domain or else I have to deny the request.

 

Thanks you for your help

 

Link to comment
Share on other sites

Unfortunately this is not a simple task...

 

Basically the there is a simple way to ask the client what domain they posted from however this is not trust worthy information as it is easily changed by a cleaver client.  (This is called the referral address)

 

I would suggest you setup authentication if you need to be certain the post is originating from the right place, alternatively you could use session management.  It really depends on what you are trying to do?

Link to comment
Share on other sites

I had to edit this post because I read it wrong. I know what you're saying now.

 

Sorry, kritical is right. It is complicated... but u can try making the form page set a URL cookie like this:

 

setcookie("url", $_SERVER['SERVER_NAME'], time()+3600, "/directory_of_your_form_and_form_processor/", ".domain.of.your.site.com");

 

And then on the page which processes your form info, write this:

 

if ($_COOKIE["url"]=="")

{

echo "You did not use the correct page";

exit;

}

else

{

//...rest of form goes here

}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.