I have a search program that has multiple input text boxes that correspond to fields in a mysql database. I would like to know if it is safe to have a custom search box where the user can enter the actual field to be searched and its value.
Like this:
<form method='post'>
<input type='text' name='param1' />
<input type='text' name='param2' />
<input type='text' name='customField' />
<input type='text' name='customValue' />
</form>
Then when it is submitted:
$param1 = mysql_real_escape_string($_POST['param1']);
$param2 = mysql_real_escape_string($_POST['param2']);
$customField = mysql_real_escape_string($_POST['customField']);
$customValue = mysql_real_escape_string($_POST['customValue']);
$query = "SELECT * FROM mytable WHERE field1 LIKE '" . $param1 . "' AND field2 LIKE '" . $param2 . "' AND " . $customField . " LIKE '" . $customValue . "'";
This is an internal webpage and only a few of us will actually see these new boxes but I would like to know if something like sql injection is possible here.