1

I am simply inserting the text that you write in the textarea in mySQL without using any extra method to protect my site... Actually i just made a test wrote the html code that creates a input textbox to the textarea and saved it into mysql, which prints me the component on the page...

How can i make it write secure content on textarea that does not allow you to write html tags or smth, I just wanna increase the security of my site.

Thanks

4

2 に答える 2

2

準備済みステートメントhttp://php.net/manual/de/mysqli.quickstart.prepared-statements.phpを使用してみてください

指定されたテキストから不要な文字をすべて削除し、最後にmysql_real_escape_stringを使用 して MySQL の文字列をエスケープします。

于 2013-09-27T12:11:22.047 に答える
2

$textareaテキストエリアの値が含まれている場合は、データベース$db_value = mysql_real_escape_string(strip_tags(trim($textarea)))に挿入$db_valueして実行できます。

strip_tagshtml タグのテキストを削除し、mysql_real_escape_string は特殊文字をエンコードして、データベースに安全に挿入できるようにします...

mysql_real_escape_string の場合: http://php.net/manual/en/function.mysql-real-escape-string.phpを確認してください

strip_tags チェックの場合: http://www.php.net/manual/en/function.strip-tags.php

于 2013-09-27T12:10:42.323 に答える