/i want to insert data with the form and written simple code for it. Html part is working well.post table is created in database but this code unable to insert data in database. Please help me/ Inserting new posts
</head>
<body>
<form method="post" action="insert_post_1.php" enctype="multipart/form-data">
<table width="600" align="center" border="10">
<tr>
<td align="center" bgcolor="yellow" colspan="6">
<h1>Insert New Post Here</h1>
</td>
</tr>
<tr>
<td align="right">Post Title:</td>
<td><input type="text" name="title" size="30"></td>
</tr>
<tr>
<td align="right">Post Author:</td>
<td><input type="text" name="author" size="30"></td>
</tr>
<tr>
<td align="right">Post Keywords:</td>
<td><input type="text" name="keywords" size="30"></td>
</tr>
<tr>
<td align="right">Post Image:</td>
<td><input type="file" name="image" size="30"></td>
</tr>
<tr>
<td align="right">Post Content:</td>
<td><textarea name="content" cols="30" rows="25"></textarea></td>
</tr>
<tr>
<td align="center" colspan="6"><input type="submit" name="submit" value="Publish Now"></td>
</tr>
</table>
</form>
</body>
</html>
/html has no issue it works perfectly fine but with this php code i am unable to detect the problem. while clicking Publish button it is not inserting data to database/
if($post_title == '' or $post_keywords == '' or $post_author == '' or $post_content == ''){
echo "<script>alert('Any of the fields is empty')</script>";
exit();
}
else{
move_uploaded_file($post_temp, "images/$post_image");
/*this part of code is not running and hence unable to insert data to database*/
$insert_query = "INSERT INTO "
. "posts (`post_id`, `post_title`, `post_date`, `post_author`, `post_image`, `post_keywords`, `post_content`)"
. " VALUES (NULL, $post_title, $post_date, $post_author, $post_image, $post_keywords, $post_content)";
if(mysql_query($insert_query)){
echo "<center><h1>Post Published Successfully</h1></center>";
}
}
}
?>