存储在数据库中的YouTube嵌入代码未出现在HTML表单中 [英] Youtube Embed code stored in database not appearing in HTML Form

查看:83
本文介绍了存储在数据库中的YouTube嵌入代码未出现在HTML表单中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UPDATE PHP页面来编辑一个网站数据库,其中包含Youtube的嵌入代码,然后在调用该表时正确显示。在更新页面中,即时调用数据库的相同部分以便能够更改/编辑嵌入代码,但它不仅仅显示原始完整代码< iframe width = 在表单中。

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 the same portion of the database to be able to change/edit the embed code but it is not displaying the original complete code only <iframe width= in the form.

<html>
<?
if (isset($_POST['update'])) {
?>

  <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="<?= $video['videoLink'] ?>" /> <br />
      <input type="hidden" name="videoId" value="<?= $video['videoId'] ?>" />
      <input type="submit" value="Save" name="save" />  
  </form>

<?
  }//endIf
?>
</html>


推荐答案

您必须使用htmlentities将引号转换为HTML实体。

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

$str = htmlentities($str);

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

像这样使用它:

  <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>

另外,如果您打算将这些数据保存到数据库中,请务必对数据调用html_entity_decode在将表单保存到数据库之前由表单发送。

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.

这篇关于存储在数据库中的YouTube嵌入代码未出现在HTML表单中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆