Skip to content Skip to sidebar Skip to footer

Youtube Embed Code Stored In Database Not Appearing In HTML Form

I have an UPDATE php page to edit a websites database that contains Youtube's embed code which then gets properly displayed when the table is called. On the update page im calling

Solution 1:

You have to use htmlentities to convert the quotes to HTML entities.

$str = htmlentities($str);

http://php.net/manual/en/function.htmlentities.php

Use it like this:

  <form method="post">
      Submitter: <input type="text" name="submitter" value="<?= $video['submitter'] ?>" /> <br />
      Video Title: <input type="text" name="videoTitle" value="<?= $video['videoTitle'] ?>" /> <br />
      Channel Name: <input type="text" name="channelName" value="<?= $video['channelName'] ?>" /> <br />
      Video Link: <input type="text" name="videoLink" value="<?= htmlentities($video['videoLink']) ?>" /> <br />
      <input type="hidden" name="videoId" value="<?= $video['videoId'] ?>" />
      <input type="submit" value="Save" name="save" />  
  </form>

Also if you are going to be saving this data into a database be sure to call html_entity_decode on the data being sent by the form before saving it to the database.


Post a Comment for "Youtube Embed Code Stored In Database Not Appearing In HTML Form"