I am new to php and i am making my first script as a play about and to help me improve. Im stuck at a part and cant seem to find any help anywhere. I am wanting to have a little script on my site, So in my admin panel i can go to add video, Then have a form where i paste a youtube url, Then that will add that youtube video to my websites page. can anyone help me with this please?
You'd have better luck posting specific issues in this forum rather than one so broad There's a few processes involved in what you're talking about. When the administrator submits a form, you'll probably want to extract the video ID from the url, and store the result in a database. It's probably going to be easier to use mysql than any of the alternatives. Here's a simple example regarding PDO database connectivity in PHP: http://php.tutorialref.com/pdo-mysql-connect-example.html You'd then need the page on your site where you want to display the videos, to fetch the IDs from the database and output Youtube's embed code, supplementing the ID with the result from the database. i.e.: print '<iframe width="560" height="315" src="http://www.youtube.com/embed/' . $result['videoId'] . '" frameborder="0" allowfullscreen></iframe>'; PHP:
After hours n hours of trial and error i finally managed to create this, In my admin panel i add only the youtube id http://www.youtube.com/watch?v=f1KdF_EExXE Then on my homepage i set it to echo out pretty much as you had put. It works great im happy with it,it took hours to figure out n get to work, but its 1 more thing i can say i have learnt Thanks for your reply tho mate
I know how to embed a youtube video,thats easy. But its abit more then that what i needed here, i needed a script to add them. I managed to make it eventually This thread can be closed.