Jump to content

data insertion


Alfraganus

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>
<html>
<head>
<title>inserting data</title>
</head>
<body>
<form action="insert_post.php" method="post" enctype="multipart/form-data">
<table width="800" align="center" border="10">
<tr>
<td align="center" bgcolor="green" colspan="2"><h1> Insert new post</h1></td></tr>
<tr>
<td>Post title</td>
<td><input type="text" name="title"></td>
</tr>
<td>Post author</td>
<td><input type="text" name="author"></td>
</tr>
<td>Post image</td>
<td><input type="file" name="image"></td>
</tr>
<td>Post content</td>
<td><textarea name="content" cols="60" rows="20 "></textarea>></td>
</tr>
<td align="center">submit</td>
<td><input type="submit" align="center" name="submit" value="upload"></td>
</tr>
</body>
</html>
<?php
include ('db.php');
if (isset($_POST['submit'])) {
$title=$_POST['title'];
$date=date('d-m-y');
$author=$_POST['author'];
$content=$_POST['content'];
$image=$_FILES['image']['name'];
$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...