Jump to content

getting a youtube video to play


natasha23

Recommended Posts

Hi i am having trouble getting a you tube video to play. I have a form with a drop down menu and depending what option the user selects i want a different video to play. I am doing this via an if statement. But it doesnt run and it is printing out "no video available" before the user clicks on the submit button on the form. Can anyone tell me where i making mistakes please???

 

if ($shape == "circle" && $colour == "red") {

 

echo "<A href='http://www.youtube.com/watch?v=8RHbBe-lvrc?'</A>";

}

echo "No video Available";

Link to comment
Share on other sites

ok i re adjusted my code. I wanted it to only strat once the submit button is pressed. But it still doesn't work, anyone got any ideas?

 

echo "<form name=shape test method=post>// this is my form where the user picks a color

<Select NAME=$color>

<Option>red</option>

<Option>blue</option>

</Select><input type='submit' name='Mix' value='Mix' />

</form>";

 

if (isset($_POST['submit']))

{

if ($shape == "circle" && $color == "red")

{

$url = "http://www.youtube.com/";

$content = file_get_contents($url);

 

echo $content;

}

else

{

echo "No video Available";

}

}

//Shape is chosen by the user from whatever shape they clicked on in previous page. I have tested shape with: echo $shape and it prints out circle

 

Link to comment
Share on other sites

i dont see how getting the contents of a youtube page is going to play the video.

 

you probably want to look at the youtube embed code:

<object width="480" height="385">
<param name="movie" value="http://www.youtube.com/v/4RriC_GnIIE&hl=en_US&fs=1&"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/4RriC_GnIIE&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed>
</object>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.