Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8888401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:01:24+00:00 2026-06-14T22:01:24+00:00

I have a website, and on it you can post a YouTube video link,

  • 0

I have a website, and on it you can post a YouTube video link, and when you do, it gets the ID from it (the 11 characters) and puts it in the database. Then, you can view the video on a page and it gets the YouTube title and author with http://gdata.youtube.com/feeds/api/videos/ID and puts it onto a page with embed code. I would like to know how to not allow them to post private video links, like maybe there’s a certain check I could do. This is what I have so far for posting the links:

if(isset($_POST['video'])){
  $error = array();
  if(filter_var($_POST['videourl'], FILTER_VALIDATE_URL) !== false){
    if(strpos($_POST['videourl'],'youtube.com')){
        preg_match('/[\\?\\&]v=([^\\?\\&]+)/',$_POST['videourl'],$video_embed);
        $video_embed = $video_embed[1];
    }elseif(strpos($_POST['videourl'],'youtu.be')){
        $video_embed = substr( parse_url($_POST['videourl'], PHP_URL_PATH), 1 );
    }else{
        $error[] = 'Invalid link';
    }
  }else{
    $error[] = 'Invalid link';
  }
  $video_exist = mysql_num_rows(mysql_query("SELECT interest_vid FROM interest_videos WHERE interest_vid = '$video_embed'"));
  $interest_exist = mysql_query("SELECT name FROM interests WHERE name = '".$_POST['interest_for_video']."'");
  if(!empty($_POST['interest_for_video']) && mysql_num_rows($interest_exist) != 0){
    $interest = strtolower(mysql_real_escape_string(strip_tags($_POST['interest_for_video'])));
    $interest_id = mysql_result(mysql_query("SELECT id FROM interests WHERE name = '$interest'"), 0);
  }else{
    $error[] = 'Must specify an interest. ';
  }
      if(empty($error)){
        if($video_exist == 0){
            $result2 = mysql_query(" INSERT INTO interest_videos (user_id,interest_id,interest_vid) VALUES ('".$_SESSION['id']."','$interest_id','$video_embed')") or die(mysql_error());
            if(!$result2){
                die('Could not delete from database: '.mysql_error());
            }else{
                //$error_message = '<a href="#" onclick="toggle2(\'deletewebsite\', this); return false;"><div id="deletewebsite" class="success">Video Created</div></a>';
                header("Location: /interest/video.php?interest=".$interest_id."&video=".$video_embed."");
            }
        }else{
            $error_message = '<a href="#" onclick="toggle2(\'deletewebsite\', this); return false;"><div id="deletewebsite" class="error">That video already exists</div></a>';
        }
      }else{
        $error_message = '<a href="#" onclick="toggle2(\'deletewebsite\', this); return false;"><div id="deletewebsite" class="error">';
        foreach($error as $key => $values){
            $error_message.= "$values";
        }
        $error_message.="</div></a>";
        }
}

Is there a check that I could put in there so they can’t post private videos?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:01:26+00:00Added an answer on June 14, 2026 at 10:01 pm

    I figured it out (it’s been a long time since I’ve posted this question, and it’s been a while since I have figured it out, but I thought I should answer it) and all I had to do was check if it could load the file with the boolean, like so:

    if(@DOMDocument::load("http://gdata.youtube.com/feeds/api/videos/".$video_embed) === false){
        $error[] = 'Invalid video';
    }
    

    And I put the @ in front of it so it wouldn’t display all of the errors it gives when it can’t load it 🙂

    Hope this will help someone in the future!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a website wherein a user can post information from our website to
So, I have a user driven website. Users can post whatever they want, even
I need to retrieve a value from a website (can vary and I have
Well, my website can not redirect to https://www.facebook.com/QuaFootSpa from http://quafootspa.com/ I have tried redirection
I have a website where users can post their articles. I would like to
On my website I have tags that people can use to post on my
I have a blog in my website where only authenticated users can post. If
I have a simple website where users can post ads, i want to set
Quick sum up: I have a social website where users can follow/post/vote etc. I
I have a website where people post links from Google+. I am trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.