是什么让这个页面提前被切断了?

时间:2017-07-19 19:30:41

标签: php html mysql mysqli

我将包含整个php文件以供参考,因为我很难弄清楚冲突发生在什么时候。问题是页面停止显示下拉菜单后面的其余表单。当php的第一部分被注释掉时,一切正常,所以我怀疑那里有什么问题,但我需要帮助来解决它。

<?php
if(isset($_GET['update_post'])) {
    $postTitle = $_POST['title'];
    $postAuthor = $_POST['author'];
    $postCatId = $_POST['post_cat_id'];
    $postStatus = $_POST['status'];
    $postContent = $_POST['content'];
    $postImage = $_FILES['image']['name'];
    $postImageTemp = $_FILES['image']['tmp_name'];
    $postTags = $_POST['tags'];
    $postDate = date('d-m-y');
    $postCommentCount = 4;

    move_uploaded_file($postImageTemp, "../images/$postImage");

    $queryupdate = $db->prepare("UPDATE posts (post_category_id, post_title, post_author, post_date,
                        post_content, post_image, post_tags, post_comment_count, post_status) VALUES
                        ($postCatId, '$postTitle', '$postAuthor', now(), '$postContent', '$postImage',
                        '$postTags', '$postCommentCount', '$postStatus')");

    if (!$queryupdate) {
        die("MySQL Fatal Exception: " . $db->error);
        exit;
    }
    else {
        $queryupdate->execute();
        echo "<strong class='text-success'>Post Successfully Created</strong>";
    }
}


?>

<?php
if(isset($_GET['post_id'])) {
    $getID = $_GET['post_id'];
    echo $getID;
    $query = $db->prepare("SELECT * FROM posts WHERE post_id = $getID");
    $query->bind_result($id,$catId,$title,$author,$date,$content,$image,$tags,$comments,$status);
    $query->execute();
}
?>
<form action="" method="post" enctype="multipart/form-data">
    <div class="form-group">
        <label for="title">Post Title</label>
        <input value="<?php echo $title; ?>" type="text" class="form-control" name="title">
    </div>

    <div class="form-group">
        <label for="post_category">Post Category</label>
        <br>
        <select name="" id="">
            <?php
            $stmt = $db->prepare("SELECT * FROM `categories`");
            if (!$stmt) {
                echo "Connection fail";
                exit;
            }
            $stmt->bind_result($catIDdrop, $catTitle);
            $stmt->execute();
            while ($stmt->fetch()) {
                echo "<option value =''>$catTitle</option>";
            }
            $stmt->close();
            ?>

        </select>

    </div>

    <div class="form-group">
        <label for="post_author">Post Author</label>
        <input value="<?php echo $author; ?>" type="text" class="form-control" name="author">
    </div>

    <div class="form-group">
        <label for="post_status">Post Status</label>
        <input value="<?php echo $status; ?>" type="text" class="form-control" name="status">
    </div>

    <div class="form-group">
        <label for="post_image">Post Image</label>
        <img alt="post img" src="../images/<?php echo $image; ?>">
        <input type="file" name="image">
    </div>

    <div class="form-group">
        <label for="post_tags">Post Tags</label>
        <input value="<?php echo $tags; ?>" type="text" class="form-control" name="tags">
    </div>

    <div class="form-group">
        <label for="post_content">Post Content</label>
        <textarea value="<?php echo $content; ?>" class="form-control" name="content" id="" cols="30" rows="10"></textarea>
        </textarea>
    </div>

    <div class="form-group">
        <input class="btn btn-primary" type="submit" name="update_post" value="Update">
    </div>
</form>

0 个答案:

没有答案