-2

Okay, so typically I would write the following:

<input type='text' class='form-control' name='name' value='<?=$user['name'];?>'>

However, because I am using ' in my HTML, and if the name has a ' in it, (i.e. the last name is O'Brian for instance) It doesn't echo correctly, because the value is ending the input abruptly.

Of course a simple solution is to use " quotation marks with my html, but that doesn't help - because what about when I want to echo quotation marks as well? What can I do?

Chud37
  • 4,907
  • 13
  • 64
  • 116

1 Answers1

0

Use <input type='text' class='form-control' name='name' value='<?php echo htmlentities($user['name'], ENT_QUOTES); ?>'>

muton
  • 382
  • 2
  • 9
Gaurav Chauriya
  • 304
  • 2
  • 12
  • Why should the OP "use this code"? A **good answer** will always have an explanation of what was done and why it was done that way, not only for the OP but for future visitors to SO that may find this question and be reading your answer. – RiggsFolly Aug 23 '16 at 13:17