ユーザー入力を許可するスニペット
//fetch user input and pass it in URL
alertify.prompt("Please enter note/remarks for this Form (optional):", function (e,value) {
if (e) {
alertify.success("Form has been submitted");
$.post(SITE_URL+"someController/someAction",$("#frm_submit").serialize()+ "&user_id="+user_id+"&comment="+value, function( data ) {
});
}else{
alertify.error("Your Form is not submitted");
}
});
ユーザー入力:すべての Google 社員のための My Project Google R&D
フォームが投稿されると、入力は完了せず、次のように表示されます
echo $_POST['comment']
My Project Google Rを印刷します
&
ここで、ユーザーがコメントの ように特殊文字を入力すると、入力が壊れます
htmlentities($_POST['comment'])
andを使用してみhtmlspecialchars($_POST['comment'], ENT_QUOTES, 'UTF-8')
ましたが、機能しません。
ユーザーが特殊文字を入力できるようにするにはどうすればよいですか?
PS:この値をデータベースに保存していません