亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

How to implement the function of adding content

Now we will implement the function of adding web content. Content addition mainly involves adding titles, content, videos, categories, etc. to the database, and then displaying them on the main page.

First, we need to add a jump link in list.php , jump to add.php:

37.png

In video Create an upload file under the document to store the locally uploaded video source files.

You need to introduce an upload class here: uploads.class.php class. This class is placed in the admin folder and is used to upload video files to the database. Call this class in add.php.

uploads.class.zip

<?php
 include_once("uploads.class.php");
  $title = isset($_POST['title'])?$_POST['title']:"";
  $name = isset($_POST['name'])?$_POST['name']:"";
  $video = isset($_POST['video'])?$_POST['video']:"";
   // 調(diào)用uploads類
  $upobj=new upload();
  $ret=$upobj->upload_file();
  if($ret['status']>0)
  {
    $video=$ret['msg'];
  }else{
    $video='';
    die($ret['msg']);
  }
?>

Then it is determined that only when the title, content and video are added at the same time can it be uploaded to the database and jump to the main display page .

<?php
if($title && $name && $video)
{
        //注意video 的本地路徑
    $video = str_replace("../","/",$video);
    $sql = "insert into list(title,name,time,video) values('".$title."','".$name."','".time()."','".$video."')";
    $rel = mysqli_query($link,$sql);
    if($rel)
    {
        echo "<script type='text/javascript'>alert('添加成功!');window.location='list.php'</script>";
    }
}else{
  echo "<script type='text/javascript'>alert('添加失敗,請(qǐng)重新添加');</script>";
}
?>


Continuing Learning
||
<?php header("content-type:text/html;charset=utf-8"); include("config.php"); if($_POST){ include_once("uploads.class.php"); $title = isset($_POST['title'])?$_POST['title']:""; $name = isset($_POST['name'])?$_POST['name']:""; $video = isset($_POST['video'])?$_POST['video']:""; // 調(diào)用uploads類 $upobj=new upload(); $ret=$upobj->upload_file(); if($ret['status']>0) { $video=$ret['msg']; }else{ $video=''; die($ret['msg']); } if($title && $name && $video) { $video = str_replace("../","/",$video); $sql = "insert into list(title,name,time,video) values('".$title."','".$name."','".time()."','".$video."')"; $rel = mysqli_query($link,$sql); if($rel) { echo "<script type='text/javascript'>alert('添加成功!');window.location='list.php'</script>"; } }else{ echo "<script type='text/javascript'>alert('添加失敗,請(qǐng)重新添加');</script>"; } } ?>
submitReset Code