Htmlspeacialchars
Started on the old forum in August 2008 · view the original in the archive · old links redirect here
yes so use it
$txt = mysql_real_escape_string($_POST["txt"]);
$txt = str_replace('&', "&", $txt);
$txt1 = htmlspecialchars($txt);
$result = mysql_query("INSERT INTO text_table SET message='".$txt1."'");
mine is secured and yours is vulnerable.so use mine and google for mysql_real_escape_string() or mysql_escape_string()
i need someone to help me understand htmlspecialchars:
correct me if im wrong.... example i add an address http://domain.com/ref=2&id=1 in a submit form (datatosend.php), the address is then posted to (procdata.php) where the page looks like this
else if($action=="addaddy")
{
$addy = mysql_real_escape_string($_POST["addy"]);
$addy= str_replace('&', "&", $addy);
{
echo head($thm);
echo pc();
$addy1 = htmlspecialchars($addy);
$result = mysql_query("INSERT INTO address SET addy='".$addy1."'");
if($result)
{
echo "Address Added Successfully";
}
else
{
echo "Database Error!
";
echo "Please contact the administrator";
}
}
echo homelink($ses);
echo pe();
echo foot();
}
http://domain.com/ref=2&id=1 is posted to this form and string & is then replaced by & and then what happens at htmlspecialchars function. as far as i know after it has passed all functions it is then sent to the db