Note that there are some explanatory texts on larger screens.

plurals
  1. PONot allowing people to post private youtube video links
    primarykey
    data
    text
    <p>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 <a href="http://gdata.youtube.com/feeds/api/videos/" rel="nofollow">http://gdata.youtube.com/feeds/api/videos/</a><em>ID</em> 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:</p> <pre><code>if(isset($_POST['video'])){ $error = array(); if(filter_var($_POST['videourl'], FILTER_VALIDATE_URL) !== false){ if(strpos($_POST['videourl'],'youtube.com')){ preg_match('/[\\?\\&amp;]v=([^\\?\\&amp;]+)/',$_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']) &amp;&amp; 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 = '&lt;a href="#" onclick="toggle2(\'deletewebsite\', this); return false;"&gt;&lt;div id="deletewebsite" class="success"&gt;Video Created&lt;/div&gt;&lt;/a&gt;'; header("Location: /interest/video.php?interest=".$interest_id."&amp;video=".$video_embed.""); } }else{ $error_message = '&lt;a href="#" onclick="toggle2(\'deletewebsite\', this); return false;"&gt;&lt;div id="deletewebsite" class="error"&gt;That video already exists&lt;/div&gt;&lt;/a&gt;'; } }else{ $error_message = '&lt;a href="#" onclick="toggle2(\'deletewebsite\', this); return false;"&gt;&lt;div id="deletewebsite" class="error"&gt;'; foreach($error as $key =&gt; $values){ $error_message.= "$values"; } $error_message.="&lt;/div&gt;&lt;/a&gt;"; } } </code></pre> <p>Is there a check that I could put in there so they can't post private videos?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload