Jump to content

Escaping strings


ChaosKnight

Recommended Posts

Hi, I have a form that posts data to the database, so I'm very concerned about the security...

 

My question is if this will work?:

    foreach ($_POST as $field => $value){
      $$field = mysql_real_escape_string(strip_tags(trim($value)));
    }

 

Any help will be greatly appreciated

Link to comment
https://forums.phpfreaks.com/topic/200364-escaping-strings/
Share on other sites

What's $$field? You'll need to use $_POST[$field].

 

http://dk2.php.net/manual/en/language.variables.variable.php

 

 

As for the question, you don't need to use strip_tags when inserting into a database, and I would be wary about creating variables dynamically like that. You risk overriding other variables, which is why register globals is discouraged and deprecated.

Link to comment
https://forums.phpfreaks.com/topic/200364-escaping-strings/#findComment-1051492
Share on other sites

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.