I have been given work to make sure that textboxes in a form can not be used for sql injection. The details in these textboxes are updating fields in a mySQL table.
I am new to this and didn't think about it at all until recently. Here is an example of what is going on:
<input type="text" name="myTextbox">
....
and then in the php
$sqlStr = "UPDATE myTable, SET field1='".$_POST[myTextbox]." WHERE ID=1";
In order for someone to hack this, don't they need a ' to close the "field1" variable? php automatically escapes this character with a \ . Is this enough or am I being really naive?
If this is not enough, would it be ok to use the mysql_real_escape_string function?
Thanks
A computer always does what you tell it to, but rarely does what you want it to.....
I am new to this and didn't think about it at all until recently. Here is an example of what is going on:
<input type="text" name="myTextbox">
....
and then in the php
$sqlStr = "UPDATE myTable, SET field1='".$_POST[myTextbox]." WHERE ID=1";
In order for someone to hack this, don't they need a ' to close the "field1" variable? php automatically escapes this character with a \ . Is this enough or am I being really naive?
If this is not enough, would it be ok to use the mysql_real_escape_string function?
Thanks
A computer always does what you tell it to, but rarely does what you want it to.....