Jump to content

[SOLVED] Enforcing POST submission location


phpknight

Recommended Posts

As many do, I am considering checking my scripts to make sure the forms are being submitted from my site.  The problem with that is I wonder if certain browsers or firewalls can just block referrer value so I cannot access it.  In order words, is it possible that the value could just be NULL, and then I end up blocking real users?  I know when I track website referrers, the value is frequently not set, so wouldn't this be the same case when tracking script locations using PHP?

Link to comment
Share on other sites

Yep. Some firewalls and some browsers do block the http_referer. It can also be forged.

 

See this post for a discussion on it:

 

http://www.phpfreaks.com/forums/index.php/topic,165553.0.html

 

The solution: validate your forms properly. Do not rely on any html/javascript validation. Just because you have a select box, dont assume the data is one of the options. Just because you set a maximum size of 2, dont assume thats the maximum length you will recieve etc.

 

As long as you properly validate your form data, it doesn't matter where it comes from.

Link to comment
Share on other sites

You might be right, but it can never be a replacement for server-side checks.  I have yet to find a good use for javascript--Yahoo! Mail even ruined AJAX, but please let me know what you like about it.  I do have the huge javascript book, but I am only a little way through it.

Link to comment
Share on other sites

Assign each post variable with a function (Custom) So that even if the data is forged then you can make a error page like:

 

"Hey Dont You Try To Hack My Website! Get A Life! Obviously You Have No Friends And Live In Your Mothers Basement!"

 

Or something like that...

 

Sorry for my emotions I could post more but I probably would get my account banned. Its so fustrating getting your site hacked, so many SQL Querys to undo!

Link to comment
Share on other sites

Well you can make a md5 key store it in the session on accessing each form and pass it on as a hidden variable and on the next page check $_SESSION['md5_code'] == $_POST['md5_code'] something like that

 

Indeed. But not fool proof. Hence why the only real solution is full validation of the form data.

Link to comment
Share on other sites

but it can never be a replacement for server-side checks.

Absolutely.  The key part of my statement is when used correctly.  Replacing server side validation with Javascript validation on the client machine is a very improper use of Javascript.

 

Using Javascript to give hints to a valid user that the server will just reject their submission before they even submit it is a great use of Javascript.

 

There are many other great uses for it, but you really have to learn how to do it properly, part of which includes, IMO, not putting any Javascript in your HTML.

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.