I'm trying to validate a youtube url taken from a form field. The way I have it setup isn't catching any error no matter what I put in. I use getVideoId() to extract the video id from the url which works.
if ($_POST['video_url'] != null && $_POST['video_url'] != 'Youtube URL') {
$vid_url = $_POST['video_url'];
$video_id = getVideoId($vid_url);
$headers = get_headers('http://gdata.youtube.com/feeds/api/videos/' . $video_id);
if (strpos($headers[0], '200')) {
$video_url = $vid_url;
} else {
$output .= 'This is not an existing youtube video<br/>';
}
}
The $output is set to null and I check against that before processing the form which works for how I validate other fields so it's just this method that is failing.