mysqli_query无法正常工作INSERT INTO无法正常工作

时间:2018-05-23 20:02:40

标签: php mysql

好的,所以这是非常基本但它让我疯狂

<div class="heading"><h2>Make a post<h2></div>
            <form action="post.php" method="POST">
            <div class="head"><h3>Title</h3></div>
                <textarea name="title" rows="2" cols="45"></textarea>
            <div class="desc"><h3>Content</h3></div>
                <textarea name="description" rows="15" cols="45"></textarea><br>
            <input type="submit" value="Submit">
            <p id="error_p"><?php echo (!empty($_SESSION['post_message']))? $_SESSION['post_message']:""; ?></p>
            </form>

html部分

if(!empty($_POST['title']) && !empty($_POST['description']))
{


    $title=$_POST['title'];
    $description=$_POST['description'];
    $user_id=$_COOKIE['user_id'];


    $query="INSERT INTO posts (title,description,user_id)
    VALUES('".$title."','".$description."','".$user_id."');";
    $result=mysqli_query($conn,$query);
    if($result)
    {
        $_SESSION['post_message']="Posting succ";
        header('Location: profile.php');
    }
    else
    {
        $_SESSION['post_message']="something gone wrong";
        header('Location: profile.php');
    }

}

php部分

我只是找不到问题,我一直在&#34;出了问题&#34;无论我做什么都会出错。

0 个答案:

没有答案