Notice: Undefined index: video_code in C:\xampp\htdocs\home_teacher_upload.php on line 12 : <p>Hi so I keep running into this error and I was wondering how can I fix it! It is very important because this project is for a school degree.</p>

<p>This form basically will be used for uploading youtube embed codes and call them in another page!
I am using strip_tags but it seems it will not work because it says undefined variables both $video_title and $video_code.So this is what the page looks like when i first open it:<a href="https://imgur.com/a/hTsW7" rel="nofollow noreferrer">http://imgur.com/a/hTsW7</a>
and this is when i click the submit button:
<a href="https://imgur.com/a/ToVV8" rel="nofollow noreferrer">http://imgur.com/a/ToVV8</a> 
I know its a duplicate but I have tried so many options found here but none seems to work!I tried isset(); , I tried $_POST[] but no better results.I also tried to change the whole registration and login form but still nothing!
What are those errors and why
I am new into PHP so sorry for the bad explanation!</p>

<p>This is the home_teacher_upload.php :</p>

<pre><code>&lt;?php

require_once("session.php");
require_once("class.user.php");

$teacher = new USER();

if(isset($_POST['btn-submit']))
{
   $video_title = strip_tags($_GET['video_title']);
   $video_code = strip_tags($_GET['video_code']);

  if ($video_title == "") {
    $error[]="Duhet të vendosni titullin fillimisht!";
  }
    echo "&lt;h3&gt;Videoja u ngarkua me sukses!&lt;/h3&gt;";
  }
   try {
        $stmt = $teacher-&gt;runQuery("SELECT video_title, video_code FROM videos WHERE video_title=:video_title OR video_code=:video_code");
      $stmt-&gt;execute(array(':video_title'=&gt;$video_title, ':video_code'=&gt;$video_code));
      $row=$stmt-&gt;fetch(PDO::FETCH_ASSOC);

      if($row['video_title']==$video_title) {
        echo "&lt;h3&gt;Ky titull është jo valid!&lt;/h3&gt;";
      }
      else if($row['video_code']==$video_code) {
        $error[] = "Kjo video aktualisht është e ngarkuar";
      }
      else
      {
        $teacher-&gt;submit_video($video_title,$video_code);  
               }
      } 

      catch (PDOException $e) {

          echo $e-&gt;getMessage();   

      }





?&gt;
&lt;link href="img/favicon.png" rel="shortcut icon" /&gt;
&lt;!DOCTYPE html&gt;
&lt;head&gt;
&lt;link rel="stylesheet" href="bootstrap/css/bootstrap.min.css"&gt;
&lt;link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Cookie"&gt;
&lt;link rel="stylesheet" href="css/user.css"&gt;
&lt;link rel="stylesheet" href="bootstrap/fonts/font-awesome.min.css"&gt;
&lt;link href="https://fonts.googleapis.com/css?family=Fjalla+One" rel="stylesheet"&gt;
&lt;link href="https://fonts.googleapis.com/css?family=Patua+One" rel="stylesheet"&gt;
&lt;link href="https://fonts.googleapis.com/css?family=Bree+Serif" rel="stylesheet"&gt;
&lt;link href="https://fonts.googleapis.com/css?family=Anton" rel="stylesheet"&gt;
&lt;link href="https://fonts.googleapis.com/css?family=Hammersmith+One" rel="stylesheet"&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;link href="css/bootstrap.min.css" rel="stylesheet" media="screen"&gt;
&lt;link href="css/bootstrap-theme.min.css" rel="stylesheet" media="screen"&gt;
&lt;script type="text/javascript" src="jquery-1.11.3-jquery.min.js"&gt;&lt;/script&gt;
&lt;link rel="stylesheet" href="style.css" type="text/css"  /&gt;
&lt;link rel="stylesheet" type="text/css" href="css/user.css"&gt;
&lt;title&gt;Ngarkoni video!&lt;/title&gt;
&lt;/head&gt;
&lt;script src="https://code.jquery.com/jquery-1.10.2.js"&gt;&lt;/script&gt;

&lt;body&gt;

&lt;nav class="navbar navbar-default navbar-fixed-top"&gt;
      &lt;div class="container"&gt;
        &lt;div class="navbar-header"&gt;
          &lt;button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"&gt;
            &lt;span class="sr-only"&gt;Toggle navigation&lt;/span&gt;
            &lt;span class="icon-bar"&gt;&lt;/span&gt;
            &lt;span class="icon-bar"&gt;&lt;/span&gt;
            &lt;span class="icon-bar"&gt;&lt;/span&gt;
          &lt;/button&gt;
          &lt;a class="navbar-brand" style="
          font-family: Bree Serif;"&gt;IB-Learning &lt;/a&gt;
        &lt;/div&gt;
        &lt;div id="navbar" class="navbar-collapse collapse"&gt;
          &lt;ul class="nav navbar-nav navbar-right"&gt;

            &lt;li class="dropdown"&gt;
              &lt;a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"&gt;
              &lt;span class="glyphicon glyphicon-user"&gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;span class="caret"&gt;&lt;/span&gt;&lt;/a&gt;
              &lt;ul class="dropdown-menu"&gt;
                &lt;li&gt;&lt;a href="profile.php"&gt;&lt;span class="glyphicon glyphicon-user"&gt;&lt;/span&gt;&amp;nbsp;Profili&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href="logout.php?logout=true"&gt;&lt;span class="glyphicon glyphicon-log-out"&gt;&lt;/span&gt;&amp;nbsp;Dilni&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
        &lt;/div&gt;&lt;!--/.nav-collapse --&gt;
      &lt;/div&gt;
    &lt;/nav&gt;


    &lt;div class="clearfix"&gt;&lt;/div&gt;

&lt;div class="container-fluid" style="margin-top:80px;"&gt;


&lt;/div&gt;
&lt;div class="wanna" style="text-align: center;"&gt;
&lt;h3 style="font-family: Hammersmith One;"&gt;Ngarkoni një video&lt;/h3&gt;&lt;/div&gt;
&lt;div class="form" style="text-align: center;     margin-left: 431px;
    padding-top: 13px;"&gt;
&lt;form class="submit_video" method="POST" style="text-align: center;"&gt;

  &lt;div class="form-group" style="font-family: Bree Serif; width: 28%;"&gt;
            &lt;input type="text" class="form-control" name="video_title" required placeholder="Titulli i videos" style="text-align: center;"/&gt;
        &lt;/div&gt;

  &lt;div class="form-group" style="font-family: Bree Serif;margin-left: -37px;"&gt;
            &lt;textarea name="video_code" class="form-control" style="width: 240px; margin: 0px 337px 0px 0px; height: 165px; text-align: center;" form="code" placeholder="Embed code i videos" required="true"&gt;&lt;/textarea&gt;
        &lt;/div&gt;

&lt;div class="button_form-group"&gt;
              &lt;button type="submit" class="btn btn-primary" style="margin-right: 415px;font-family: Bree Serif;" name="btn-submit"&gt;
                  Submit
                &lt;/button&gt;
            &lt;/div&gt;
&lt;/form&gt;
&lt;/div&gt;



&lt;?php include('footer.php');?&gt;
&lt;script src="bootstrap/js/bootstrap.min.js"&gt;&lt;/script&gt;
&lt;style type="text/css"&gt;
  h3{
    font-family: Bree Serif;
    text-align: center;
    padding-left: 20px;
  }
&lt;/style&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>This is session.php : </p>

<pre><code>&lt;?php

    session_start();

    require_once 'class.user.php';
    $session = new USER();

    // if user session is not active(not loggedin) this page will help 'home.php and profile.php' to redirect to login page
    // put this file within secured pages that users (users can't access without login)

    if(!$session-&gt;is_loggedin())
    {
        // session no set redirects to login page
        $session-&gt;redirect('login.php');
    }
</code></pre>

<p>and this is class.user.php : </p>

<pre><code>&lt;?php

require_once('dbconfig.php');

class USER
{   

    private $conn;

    public function __construct()
    {
        $database = new Database();
        $db = $database-&gt;dbConnection();
        $this-&gt;conn = $db;
    }

    public function runQuery($sql)
    {
        $stmt = $this-&gt;conn-&gt;prepare($sql);
        return $stmt;
    }


    public function register($uname,$umail,$upass)
    {
        try
        {
            $new_password = password_hash($upass, PASSWORD_DEFAULT);

            $stmt = $this-&gt;conn-&gt;prepare("INSERT INTO tik_students(user_name,user_email,user_pass) 
                                                       VALUES(:uname, :umail, :upass)");

            $stmt-&gt;bindparam(":uname", $uname);
            $stmt-&gt;bindparam(":umail", $umail);
            $stmt-&gt;bindparam(":upass", $new_password);

            $stmt-&gt;execute();   

            return $stmt;   
        }
        catch(PDOException $e)
        {
            echo $e-&gt;getMessage();
        }               
    }
    public function register_teacher($t_uname,$t_umail,$t_upass)
    {
        try
        {
            $new_password = password_hash($upass, PASSWORD_DEFAULT);

            $stmt = $this-&gt;conn-&gt;prepare("INSERT INTO tik_teachers(user_name,user_email,user_pass)
                                                       VALUES(:uname, :umail, :upass)");

            $stmt-&gt;bindparam(":uname", $t_uname);
            $stmt-&gt;bindparam(":umail", $t_umail);
            $stmt-&gt;bindparam(":upass", $t_new_password);                              

            $stmt-&gt;execute();   

            return $stmt;   
        }
        catch(PDOException $e)
        {
            echo $e-&gt;getMessage();
        }               
    }

    public function doLogin($uname,$umail,$upass)
    {
        try
        {
            $stmt = $this-&gt;conn-&gt;prepare("SELECT user_id, user_name, user_email, user_pass FROM tik_students WHERE user_name=:uname OR user_email=:umail ");
            $stmt-&gt;execute(array(':uname'=&gt;$uname, ':umail'=&gt;$umail));
            $userRow=$stmt-&gt;fetch(PDO::FETCH_ASSOC);
            if($stmt-&gt;rowCount() == 1)
            {
                if(password_verify($upass, $userRow['user_pass']))
                {
                    $_SESSION['user_session'] = $userRow['user_id'];
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }

        catch(PDOException $e)
        {
            echo $e-&gt;getMessage();
        }
    }

    public function doLogin_teacher($t_uname,$t_umail,$t_upass)
    {
        try
        {
            $stmt = $this-&gt;conn-&gt;prepare("SELECT user_id, user_name, user_email, user_pass FROM tik_teachers WHERE user_name=:uname OR user_email=:umail ");
            $stmt-&gt;execute(array(':uname'=&gt;$t_uname, ':umail'=&gt;$t_umail));
            $userRow=$stmt-&gt;fetch(PDO::FETCH_ASSOC);
            if($stmt-&gt;rowCount() == 1)
            {
                if(password_verify($t_upass, $userRow['user_pass']))
                {
                    $_SESSION['user_session'] = $userRow['user_id'];
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }
        catch(PDOException $e)
        {
            echo $e-&gt;getMessage();
        }
    }

        public function submit_video($video_title,$video_code)
    {
        try
        {

            $stmt = $this-&gt;conn-&gt;prepare("INSERT INTO videos(video_title, video_code) 
                                                       VALUES(:video_title, :video_code)");

            $stmt-&gt;bindparam(":video_title", $video_title);
            $stmt-&gt;bindparam(":video_code", $video_code);       

            $stmt-&gt;execute();   

            return $stmt;   
        }
        catch(PDOException $e)
        {
            echo $e-&gt;getMessage();
        }               
    }


    public function is_t_loggedin()
    {
        if(isset($_SESSION['user_session']))
        {
            return true;
        }
    }


    public function is_loggedin()
    {
        if(isset($_SESSION['user_session']))
        {
            return true;
        }
    }
    public function redirect($url)
    {
        header("Location: $url");
    }

    public function doLogout()
    {
        session_destroy();
        unset($_SESSION['user_session']);
        return true;
    }
}

?&gt;
</code></pre>

<p>Help would be appreciated</p>
