Jump to content

Sanitize form action


Eiolon

Recommended Posts

In my form tag, I have been leaving the action field blank, which I read is not good.  I read from one source that putting a # symbol in its place would be good, then I read the contrary elsewhere.  What would be a good value to place in my action field?  All my php processing is done on the same page so I do not link to a separate page.

Link to comment
Share on other sites

$_SERVER['PHP_SELF'] is not good to use as this can leave an xss attack open

 

htmlentities($_SERVER['PHP_SELF']) can avoid attacks but looks ugly

 

filter the variable

filter_var($_SERVER['PHP_SELF'], FILTER_SANITIZE_STRING);

 

it's best to just input the forms name or leave it blank

 

It's also important to sanitize the POST,GET,REQUEST,SERVER and so on values, never trust user input.

 

Before any mysql statement should sanitize them

http://php.net/manual/en/function.mysql-real-escape-string.php

 

If it always a number, make sure they use a number

http://www.php.net/manual/en/function.is-numeric.php

 

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.