Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. Please help not able to resolve, trying since three days but not able to know what the reason its throwing me such message. (below is my complete code).
  2.  
  3. <?php
  4.  
  5. $title = $_POST['title'];
  6. $datenow = date('Y/m/d');
  7. $author = $_POST['author'];
  8. $content = $_POST['content'];
  9. $image_name = $_FILES['image_name']['name'];
  10. $image_type = $_FILES['image_name']['type'];
  11. $image_size = $_FILES['image_name']['size'];
  12. $image_tmp = $_FILES['image_name']['tmp_name'];
  13.  
  14. if ($title =='' || $author =='' || $content =='') {
  15. echo "<script>alert('Any feild is empty')</script>";
  16. exit();
  17. }
  18. if ($image_type =='image/jpeg' || $image_type =='image/png' || $image_type =='image/gif') {
  19.  
  20. if ($image_size<=5000000000) {
  21. move_uploaded_file($image_tmp, "images/$image_name");
  22. }
  23. else{
  24. echo "<script>alert('Image is larger, only 50kb size is allowed')</script>";
  25. }
  26. }
  27. else{
  28. echo "<script>alert('image type is invalid')</script>";
  29. }
  30.  
  31. // insert query
  32. $sth = $con->prepare(" INSERT INTO posts (post_title, post_date, post_author, post_image, post_content) VALUE (:title,:datenow,:author,:image_name,:content) ");
  33.  
  34. $sth->bindParam(':post_title', $title);
  35. $sth->bindParam(':post_date', $datenow);
  36. $sth->bindParam(':post_author', $author);
  37. $sth->bindParam(':post_image', $image_name);
  38. $sth->bindParam(':post_content', $content);
  39.  
  40. $sth = $con->prepare(" INSERT INTO posts (post_title, post_date, post_author, post_image, post_content) VALUES (:post_title,:post_date,:post_author,:post_image,:post_content) ");
  41.  
  42. $sth->bindParam(':post_title', $title);
  43. $sth->bindParam(':post_date', $datenow);
  44. $sth->bindParam(':post_author', $author);
  45. $sth->bindParam(':post_image', $image_name);
  46. $sth->bindParam(':post_content', $content);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement