Embedding a YouTube video into a website can be achieved into two ways:
- Inserting YouTube iframe directly into the website html
- Convert YouTube video url into embed code
Inserting YouTube iframe directly into the website html
This is the easiest way to display YouTube video into your website.
Open any video on YouTube. Click share button at the bottom of screen and then navigate to Embed tab
Just copy the iframe code present in the box and paste into your website html code.
Limitation: One can only show the video, whose iframe has been added.
Convert YouTube Video URL into Embed Code
This is more useful way to show YouTube video. In This method one just need to get the YouTube video URL and with the help of code it will be automatically created into embed code url and display the video on the page.
In the example one just need to copy the YouTube video URL from the address bar and paste it into the text box. With the help of PHP code the url will be saved into the MySql table in form of embed code url and can be retrieved back to display the respective video in html iframe window.
First Create a MySql Table (to save the video url):
Code to add/update the YouTube video into the website:
Using above mentioned simple ways you can easily show youtube video on your website. Hope it will help you. Thanks