Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
注意:未定义索引:第12行C:\xampp\htdocs\home\u teacher\u upload.php中的video\u代码_Php_Mysql_Database_Pdo - Fatal编程技术网

注意:未定义索引:第12行C:\xampp\htdocs\home\u teacher\u upload.php中的video\u代码

注意:未定义索引:第12行C:\xampp\htdocs\home\u teacher\u upload.php中的video\u代码,php,mysql,database,pdo,Php,Mysql,Database,Pdo,嗨,所以我一直遇到这个错误,我想知道如何才能修复它!这是非常重要的,因为这个项目是一个学校学位 此表单主要用于上传youtube嵌入代码,并在另一个页面中调用它们! 我正在使用strip_标记,但它似乎不起作用,因为它显示未定义的变量$video_title和$video_code。因此,这就是我第一次打开页面时的样子: 这就是我点击提交按钮的时候: 我知道这是一个重复,但我已经尝试了这么多的选择在这里找到,但似乎没有工作!我试过isset(),我尝试了$u POST[],但没有更好的结果。我还

嗨,所以我一直遇到这个错误,我想知道如何才能修复它!这是非常重要的,因为这个项目是一个学校学位

此表单主要用于上传youtube嵌入代码,并在另一个页面中调用它们! 我正在使用strip_标记,但它似乎不起作用,因为它显示未定义的变量$video_title和$video_code。因此,这就是我第一次打开页面时的样子: 这就是我点击提交按钮的时候: 我知道这是一个重复,但我已经尝试了这么多的选择在这里找到,但似乎没有工作!我试过isset(),我尝试了$u POST[],但没有更好的结果。我还尝试更改整个注册和登录表单,但仍然没有任何结果! 这些错误是什么?为什么 我是PHP新手,很抱歉解释得不好

这是home_teacher_upload.php:

<?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 "<h3>Videoja u ngarkua me sukses!</h3>";
  }
   try {
        $stmt = $teacher->runQuery("SELECT video_title, video_code FROM videos WHERE video_title=:video_title OR video_code=:video_code");
      $stmt->execute(array(':video_title'=>$video_title, ':video_code'=>$video_code));
      $row=$stmt->fetch(PDO::FETCH_ASSOC);

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

      catch (PDOException $e) {

          echo $e->getMessage();   

      }





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

<body>

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

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


    <div class="clearfix"></div>

<div class="container-fluid" style="margin-top:80px;">


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

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

  <div class="form-group" style="font-family: Bree Serif;margin-left: -37px;">
            <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"></textarea>
        </div>

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



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

恩加科尼视频!
切换导航
Njarkoni një视频 提交 h3{ 字体系列:Bree衬线; 文本对齐:居中; 左侧填充:20px; }
这是session.php:

<?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->is_loggedin())
    {
        // session no set redirects to login page
        $session->redirect('login.php');
    }

注意:未定义索引/未定义偏移

当您(或PHP)尝试访问未定义的索引时,会出现此通知 数组的一部分

你需要先像下面这样检查

if(isset($_GET['video_code'])){

}
那么你的情况呢

$video_code = isset($_GET['video_code']) ? strip_tags($_GET['video_code']): ' ';
在访问该索引之前,请检查该索引是否存在

为此,您可以使用

:


我不知道该怎么做!所以在“my_index”中,我应该输入变量的名称?@AvniBeka no这只是一个例子,请参见上面的updateYeah,所以我的实际代码是strip_标签($_POST['video_title');我应该按照你在上面写的代码,用视频标题替换我的索引。这里你需要了解的基本情况是,你正在尝试访问未定义索引的数组元素,这就是为什么我们首先使用isset()函数进行验证。我也看到了这一点,并尝试了那里的选项,但它们不起作用!您在home\u teacher\u upload.php页面上收到的URL是什么?该URL?????@AvniBeka URL是。查看URL或使用
var\u dump($\u GET)
检查您在
$\u GET
superglobal中获得的内容。它显示array=0;
$video_code = isset($_GET['video_code']) ? strip_tags($_GET['video_code']): ' ';
//isset()
$video_code = isset($_GET['video_code']) ? strip_tags($_GET['video_code']): '';

// OR

//array_key_exists()
$video_code = array_key_exists('video_code',$_GET) ? strip_tags($_GET['video_code']): '';