javascript - PHP - Show special characters -


snippet allow user input

//fetch user input , pass in url alertify.prompt("please enter note/remarks 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 not submitted");     } }); 

user input: my project google r&d every googler

when form post input not complete , shows below

echo $_post['comment'] prints my project google r

here if user inputs special characters & in comment, breaks input

tried using htmlentities($_post['comment']) , htmlspecialchars($_post['comment'], ent_quotes, 'utf-8') not working.

how allow user input special characters ?

p.s : not saving value in database

as daan suggested, & breaks url in javascript. pls find updated snippet worked me

//fetch user input , pass in url alertify.prompt("please enter note/remarks form (optional):", function (e,value) {     if (e) {                 alertify.success("form has been submitted");                 //encodes special characters in user comment                var comment = encodeuricomponent(value);                 $.post(site_url+"somecontroller/someaction",$("#frm_submit").serialize()+ "&user_id="+user_id+"&comment="+comment, function( data ) {            });      }else{        alertify.error("your form not submitted");     } }); 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -