A have this form I use to insert and update records. I have an input field <input type="text" name="fname" value="<?= $name; ?>"> When the user types something with single and double quotes, the insert into the DB works just fine. Eg. abc"de'fg" When the user wants to update the record. I fetch the data and then display the value in the input field, I get this: <input type="text" name="fname" value="abc"de'fg""> The browser only displays this value: abc which is correct because the value is terminated at the second double qoute. How can I get this to work ? Replace the double quotes with single quotes in onSubmit when the value is first inserted ? Any other solutions ?