title: How do I let a user input a video url and have the video show on the same page upon submit?
body: <p>I've seen a few similar questions, but none of the answers have worked for me. Ideally, the user would input the video url into the form, hit submit, and then the video would show below the form. Here's my code that's not working (sorry if it's messy or confusing):</p>
  
  <pre><code>&lt;form id="rp_embed_video" name="rp_embed-video" method="post" action=""&gt;
      &lt;div class="rp_block"&gt;
          &lt;label&gt;&lt;?php printf( __( 'Add Video Link:' ) ); ?&gt;&lt;/label&gt;
          &lt;input type="url" id="rp_newvid" name="rp_newvid" value="" required /&gt;
      &lt;/div&gt;
      &lt;div class="rp_block"&gt;
          &lt;label&gt;&lt;?php printf( __( 'Choose One:' ) );?&gt;&lt;/label&gt;
          &lt;input type="radio" name="rp_type" value="YouTube" required checked /&gt;
          &lt;input type="radio" name="rp_type" value="Vimeo" required /&gt;        
      &lt;/div&gt;
      &lt;div class="rp_block"&gt;
          &lt;label&gt;&lt;?php _e('Title');?&gt;&lt;/label&gt;
          &lt;input type="text" name="rp_title" value="" /&gt;
      &lt;/div&gt;
      &lt;div class="rp_block"&gt;
      &lt;?php $desc_status = (int)get_option('rp_uploader_desc',false);?&gt;
          &lt;label&gt;&lt;?php _e('Description');?&gt;&lt;?php if(!$desc_status):?&gt;&lt;span&gt;*&lt;/span&gt;&lt;?php endif;?&gt;&lt;/label&gt;
          &lt;textarea name="rp_desc" &lt;?php if(!$desc_status):?&gt;class="wpvp_require"&lt;?php endif;?&gt;&gt;&lt;/textarea&gt;
      &lt;/div&gt;
      &lt;div class="rp_block"&gt;
          &lt;div class="rp_cat" style="float:left;width:50%;"&gt;
              &lt;label&gt;&lt;?php _e('Choose category');?&gt;&lt;/label&gt;
              &lt;?php RP_Helper::rp_upload_categories_dropdown();?&gt;
          &lt;/div&gt;
          &lt;?php   
          $hide_tags = get_option('rp_uploader_tags','');
          if($hide_tags==''){ ?&gt;
          &lt;div class="rp_tag" style="float:right;width:50%;text-align:right;"&gt;
              &lt;label&gt;&lt;?php _e('Tags (comma separated)');?&gt;&lt;/label&gt;
              &lt;input type="text" name="rp_tags" value="" /&gt;
          &lt;/div&gt;
          &lt;?php   
          } 
          ?&gt;
      &lt;/div&gt;
      &lt;input type="hidden" name="rp_action" value="rp_embed" /&gt;
      &lt;p class="rp_submit_block"&gt;
          &lt;input type="submit" class="rp-submit" name="rp-embed" value="Add Video" /&gt;
      &lt;/p&gt;
  &lt;/form&gt;
  
  &lt;?php
     if (isset($_POST['rp_newvid'])) {
         // Get the video URL and put it in the $video variable
          $videoID = $_POST['rp_newvid'];
          $type = $_POST['rp_type'];
      echo rp_video_embed($_POST['rp_newvid'], '720px', '380px', $_POST['rp_type']);
     }
  ?&gt;
  
  
  &lt;?php
  function rp_video_embed($videoID,$width,$height,$type){
          if($type){
              if($videoID){
                  if($type=='YouTube'){
                      $embedCode = '&lt;iframe width="'.$width.'" height="'.$height.'" src="http://www.youtube.com/embed/'.$videoID.'" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;';
                  }
                  elseif($type=='Vimeo'){
                      $embedCode = '&lt;iframe width="'.$width.'" height="'.$height.'" src="http://player.vimeo.com/video/'.$videoID.'" webkitAllowFullScreen mozallowfullscreen allowFullScreen frameborder="0"&gt;&lt;/iframe&gt;';
                  }
                  $result = $embedCode;
              }
              else{
                  $result = '&lt;span style="color:red;"&gt;'._e('No video code is found').'&lt;/span&gt;';
              }
          }
          else{
              $result = '&lt;span style="color:red;"&gt;'._e('The video source is either not set or is not supported').'.&lt;/span&gt;';
          }
          return $result;
      }
  
  ?&gt;
  </code></pre>