php safe output -
i'm trying make "remember fields" thingy, if there 1 error won't have fill in whole form again. how can make output safe?
example:
<input type="text" name="email" value="<?php echo (isset($_post['email'])) ? htmlspecialchars($_post['email']) : ''; ?>" /> if types in " ' " (without quotes) example get:
warning: mysql_result() expects parameter 1 resource, boolean given in c:\wamp\www\pages\register.php on line 55 so tried:
<input type="text" name="email" value="<?php echo (isset($_post['email'])) ? mysql_real_escape_string($_post['email']) : ''; ?>" /> then adds lot of //////.
what should do?
i'm noob yes. thought htmlspecialchars made user input safe?
it depends on context.
htmlspecialchars() friend in html.
mysql_real_escape_string() friend in mysql.
update
you run $_post through htmlspecialchars() first this...
$encodedhtmlpost = array_map('htmlspecialchars', $_post);
Comments
Post a Comment