【发布时间】:2017-06-15 08:01:01
【问题描述】:
我的网页上有一个 html 表单字段供用户提交 YouTube“分享”视频链接。
但是,我只希望通过链接的一部分。
当使用 YouTube 的“复制和粘贴”“分享”选项时,他们的 URL 似乎都以:
我想做的(如果可能的话)是当我的用户输入完整的 URL 时...
例如: https://youtu.be/TP8RB7UZHKI
我只希望:TP8RB7UZHKI 显示在 php 结果页面上。
我希望始终省略 URL 的 https://youtu.be/ 部分(从开头剪掉)。
我可以在填写表单时指示我的网站访问者这样做,但这可能会让他们中的大多数人感到困惑,而且我无法承受错误。
我在下面包含了一个非常精简的 html 表单和 php 结果页面代码。
再次...我不知道这是否可能,但如果可以,我将不胜感激有关如何实现这一目标的建议和/或示例。
表单页面:
<!DOCTYPE html>
<html>
<head>
<style>
body {margin-top:100px; margin-left:50px;}
.videoURL{width:300px; height:25px;}
</style>
</head>
<body>
<form action="videoURLUploadResults.php" method="post" enctype="multipart/form-data">
Video URL
<input class="videoURL" ID="videoURL" name="videoURL" value="" autocomplete="off"/>
<input class="submitButton" type="submit" name="submit" value="SUBMIT">
</button>
</form>
</body>
</html>
视频 URL 上传结果 PHP 页面:
<!DOCTYPE html>
<html>
<head>
<style>body{margin-top:100px; margin-left:50px;}</style>
</head>
<body>
<?php $videoURL = ($_POST['videoURL']); echo $videoURL;?>
</body>
</html>
【问题讨论】:
标签: javascript php forms youtube trim