Jump to content

data insertion


Recommended Posts

I've been trying to insert my data to database, i've checked db connection, it is ok, but my data is not being inserted to database, it is not even showing error message, can you have a look to my codes if I have written something wrong.


<!DOCTYPE html>
<title>inserting data</title>
<form action="insert_post.php" method="post" enctype="multipart/form-data">
<table width="800" align="center" border="10">
<td align="center" bgcolor="green" colspan="2"><h1> Insert new post</h1></td></tr>
<td>Post title</td>
<td><input type="text" name="title"></td>
<td>Post author</td>
<td><input type="text" name="author"></td>
<td>Post image</td>
<td><input type="file" name="image"></td>
<td>Post content</td>
<td><textarea name="content" cols="60" rows="20 "></textarea>></td>
<td align="center">submit</td>
<td><input type="submit" align="center" name="submit" value="upload"></td>
include ('db.php');
if (isset($_POST['submit'])) {
$image_tmp=$_FILES ['image'] ['tmp_name'];
move_uploaded_file($image_tmp, "images/$image");
$query="INSERT INTO project
(post_title, post_date,post_author,post_image,post_content) VALUES ('$title','$date','$author','$image','$content')";
if (mysql_query($query)) {
echo "<script>alert('success')</script>";
else {
echo "<script>alert('oxshamadi')</script>";
Edited by Alfraganus
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...