Jump to content

YOUTUBE URL extraction help!!


jeger003

Recommended Posts

there is one more thing i need help with

 

basically the v= code is taken to display the youtube video right under the form

 

my issue is....I have no clue how to take the v=code out in the POST or GET in a FORM

 

why.....because a URL (YOUTUBE) wont work in the URL bar ( i.e. www.mysite.com/video.php?youtubeURL=http://www.youtube.com?v=AkdfOsdfj) this wont work

 

I want users to enter url then use MadTechie's code to get V and use that to get the video

 

 

does this make sense?

 

 

thanks again guys/gals

Link to comment
Share on other sites

Here is a example with a form

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TITLE</title>
</head>
<body>
<form action="" method="get">
<input name="URL" type="text" value="http://www.youtube.com?v=AkdfOsdfj" size="65" /><BR />
<input name="RUN" type="submit" value="Run IT" />
</form>
<?php
if(!empty($_GET['URL'])){
    if (preg_match('/v=([^&]+)/i', $_GET['URL'],$match)) {
    echo "Found: ".$match[1];
    } else {
    echo "No V found";
    }
}
?>
</body>
</html>

 

you can change the method from get to post

but then your need to update the 2 $_GET to $_POST

 

 

 

OH yeah and if you wanted your example URL to work

why.....because a URL (YOUTUBE) wont work in the URL bar ( i.e. www.mysite.com/video.php?youtubeURL=http://www.youtube.com?v=AkdfOsdfj) this wont work

use this code

<?php
if(!empty($_GET['youtubeURL'])){
    if (preg_match('/v=([^&]+)/i', $_GET['youtubeURL'],$match)) {
    echo "Found: ".$match[1];
    } else {
    echo "No V found";
    }
}
?>

Link to comment
Share on other sites

thanks MadTechie

 

i end up running into the same issue....when i click run it i get sent to my home page and this is what the URL looks like

 

http://mysite.com/url-test.php?URL=http%3A%2F%2Fwww.youtube.com%3Fv%3DAkdfOsdfj&RUN=Run+IT

 

I'm not able to get v= out

 

by the way im testing this in IE and FFX and same issue

 

thank you

 

 

 

Link to comment
Share on other sites

the logic is the same,

just change URL to yourtubURL

 

tested in IE & FF

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TITLE</title>
</head>
<body>
<form action="" method="get">
<input name="youtubeURL" type="text" value="http://www.youtube.com?v=AkdfOsdfj" size="65" /><BR />
<input name="RUN" type="submit" value="Run IT" />
</form>
<?php
if(!empty($_GET['youtubeURL'])){
    if (preg_match('/v=([^&]+)/i', $_GET['youtubeURL'],$match)) {
    echo "Found: ".$match[1];
    } else {
    echo "No V found";
    }
}
?>
</body>
</html>

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.