好吧,这是非常基本的,但它让我发疯
<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部分
我就是找不到问题,不管我做什么,我都会犯“出事了”的错误。
暂无答案!
目前还没有任何答案,快来回答吧!