索引未找到

时间:2014-02-25 18:58:45

标签: php content-management-system

我有这2个PHP文件,我不知道为什么但是我收到了错误:

  

SCREAM:忽略错误抑制   (!)注意:未定义的索引:第11行的D:\ wamp \ www \ admin \ 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);
    }
?>

这是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');
    }
?>

1 个答案:

答案 0 :(得分:0)

首先,您不能将空格用作以下元素的id值:id="markItUp content" 将您的id:s更改为小写字母,不要包含空格,例如:id="markitup_content"

您的错误告诉您的帖子参数中没有索引“content”的值:

$content = $_POST['content'];