简体   繁体   English

找不到索引

[英]Index not found

I have these 2 PHP files, and I don't know why but I'm getting an error: 我有以下2个PHP文件,我不知道为什么,但是出现错误:

SCREAM: Error suppression ignored for ( ! ) Notice: Undefined index: content in D:\\wamp\\www\\admin\\add-script.php on line 11 SCREAM:(!)忽略了错误抑制注意:未定义的索引:第11行的D:\\ wamp \\ www \\ admin \\ add-script.php中的内容

This is the add-script.php 这是add-script.php

<?php
    $con = mysqli_connect($host,$user,$password) or trigger_error("SQL", E_USER_ERROR);
    $db = mysqli_select_db($con,$db) or trigger_error("SQL", E_USER_ERROR);

    if (isset($_POST['send'])) {
        $title = $_POST['title'];
        $category = $_POST['category'];
        $tags = $_POST['tags'];
        $image = $_POST['image'];
        $content = $_POST['content'];
        $time = time();
        $sql = "INSERT INTO articles (article_id, article_title, article_content, article_timestamp, article_tags, article_image, article_category) VALUES ('', '$title','$content','$time','$tags','$image','$category')";

        if (!mysqli_query($con,$sql))
        {
            die('Error: ' . mysqli_error($con));
        }

        ('Location: index.php');
        mysqli_close($con);
    }
?>

and this is add.php 这是add.php

<?php
     session_start();

    if (isset($_SESSION['logged_in'])) {
        include_once ("header.php");
        include_once ("add-script.php");
?>
    <tr>
        <td>
            <form method="post" id="add" name="add" >
                <div id="left-col">
                     <h1>Add Article</h1>
                     <input type="text" name="title" placeholder="Title" />
                     <textarea name="content" rows="30" id="markItUp content" cols="106" placeholder="Content"> </textarea>
                     <input type="text" name="tags" placeholder="Tags" />
                     <input type="text" name="image" placeholder="Image Name" />
                 </div>
                 <div id="right-col">
                     <?php 
                         $result = mysql_query("SELECT * FROM category");
                         while($list = mysql_fetch_assoc($result)){
                     ?>
                     <input type="radio" name = "category" value = "<?php echo $list['category_id']; ?>">
                     <label><?php echo $list['category_name']; ?></label>
                     <?php 
                         }
                     ?>
                     <input type="submit" name="send" value="Send!" style="margin-bottom:0px;"/>
                 </div>
             </form>
         </td>
<?php    
    include_once ("footer.php");
    }
    else {
        header('Location: index.php');
    }
?>

First of all you can't use spaces as id values of elements like: id="markItUp content" Change your id:s to lowercase letters without spaces like: id="markitup_content" . 首先,您不能使用空格作为元素的id值,例如: id="markItUp content"将您的id:s更改为小写字母,不能使用空格,例如: id="markitup_content"

Your error is telling that there is no value with index "content" in your post parameters: 您的错误是,您的post参数中没有索引“ content”的值:

$content = $_POST['content'];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM