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
https://forums.phpfreaks.com/topic/241518-sanitize-form-action/
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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.