php - Escaping apostrophies and other characters in text area -


so have found form have falls apart , doesn't submit content until first apostrophe when types in apostrophe text area. how go escaping contents make mysql table? thanks!

<form action=\"./functions/notes.php\" method='post'> <input type='hidden' id='id' name='id' value='{$row['id']}' />  <textarea placeholder=\"add more notes here...\" name=\"notes\"></textarea><br /> <input type='submit' name='formnotes' id='formnotes' value='add notes' /> </form> 

then in notes.php file

$notesid = $_post['id']; $note = $_post['notes']; $date= date('y-m-d'); $result = mysql_query("update project_submissions set notes=concat(notes,'<br />".$date." ".$note."') id ='".$notesid."'"); 

apostrophes have special meaning sql, them data need "escaped" php has quick function security checks prevent database getting hacked.

$note = mysql_real_escape_string($note); 

ditto on moving away mysql , onto mysqli

with mysqli, it's similar need supply connection variable....

$note = mysqli_real_escape_string($link, $note); 

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -