Jump to content

Cleaning $_Get Data


Johnny2

Recommended Posts

When I run code just to check if the $_GET is set, can this (possibly malicious) data be harmful in this instance?... Do I only need to clean the data if I'm going to use it in a calculation or something?

 

if (isset($_GET['badGuyData'])

{

}

 

 

Thank you.

Link to comment
Share on other sites

I am not an expert on PHP security. But as far as I know, security issues primarily come into play when:

 

-- something that a user inputs is used within a database query somehow, potentially leading to SQL injection if it isn't properly escaped

-- something that a user inputs is displayed to the page without being properly escaped

 

As far as I understand it, isset() simply checks if a variable exists -- it doesn't "use" the variable, so it should be fine.

Link to comment
Share on other sites

I am not an expert on PHP security. But as far as I know, security issues primarily come into play when:

 

-- something that a user inputs is used within a database query somehow, potentially leading to SQL injection if it isn't properly escaped

-- something that a user inputs is displayed to the page without being properly escaped

 

As far as I understand it, isset() simply checks if a variable exists -- it doesn't "use" the variable, so it should be fine.

 

 

Thanks Ben,

 

Do you feel that the incomming data should be rendered harmless if I initially "clean" it with this line of code?:

 

$data_cleaned = preg_replace('#[^A-Za-z]#i', '', $data_dirty);

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...