Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Movies review</title>
  4. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  5. <meta name="description" content="" />
  6. <meta name="keywords" content="" />
  7. <!--[if lte IE 8]><script src="css/ie/html5shiv.js"></script><![endif]-->
  8. <script src="js/jquery.min.js"></script>
  9. <script src="js/jquery.poptrox.min.js"></script>
  10. <script src="js/skel.min.js"></script>
  11. <script src="js/init.js"></script>
  12. </script>
  13. <noscript>
  14. <link rel="stylesheet" href="css/skel-noscript.css" />
  15. <link rel="stylesheet" href="css/style.css" />
  16. </noscript>
  17. </head>
  18.  
  19. <body>
  20. <?php
  21. $bimage = "";
  22. if(isset($_FILES["file"]["type"]))
  23. {
  24. $validextensions = array("jpeg", "jpg", "png");
  25. $temporary = explode(".", $_FILES["file"]["name"]);
  26. $file_extension = end($temporary);
  27. if ((($_FILES["file"]["type"] == "image/png") || ($_FILES["file"]["type"] == "image/jpg") || ($_FILES["file"]["type"] == "image/jpeg"))
  28. && in_array($file_extension, $validextensions))
  29. {
  30. if ($_FILES["file"]["error"] > 0)
  31. {
  32. }
  33. else
  34. {
  35. if (file_exists("images/" . $_FILES["file"]["name"]))
  36. {
  37. }
  38. else
  39. {
  40. $sourcePath = $_FILES['file']['tmp_name']; // Storing source path of the file in a variable
  41. $targetPath = "images/".$_FILES['file']['name']; // Target path where file is to be stored
  42. move_uploaded_file($sourcePath,$targetPath) ; // Moving Uploaded file
  43. $bimage = $_FILES["file"]["name"];
  44. }
  45. }
  46. }
  47. else
  48. {
  49. }
  50. }
  51. ?>
  52. <?php
  53. //including the database connection file
  54. include "connect.php";
  55. $conn = mysqli_connect($servername, $username, $password, $dname);
  56.  
  57. if(isset($_POST['bname'])) {
  58. $bname = $_POST['bname'];
  59. $btitle = $_POST['btitle'];
  60. $bdesc = $_POST['bdesc'];
  61.  
  62.  
  63. }
  64. // checking empty fields
  65. if(empty($bname) || empty($btitle) ||empty($bimage) || empty($bdesc)) {
  66. if(empty($bname)) {
  67. echo "<font color='red'>Name field is empty.</font><br/>";
  68. }
  69. if(empty($btitle)) {
  70. echo "<font color='red'>Title field is empty.</font><br/>";
  71. }
  72. if(empty($bimage)) {
  73. echo "<font color='red'>Image field is empty.</font><br/>";
  74. }
  75.  
  76. if(empty($bdesc)) {
  77. echo "<font color='red'>Description field is empty.</font><br/>";
  78. }
  79.  
  80. //link to the previous page
  81. echo "<br/><a href='javascript:self.history.back();'>Go Back</a>";
  82. } else {
  83. // if all the fields are filled (not empty)
  84. //insert data to database
  85. $bdesc = str_replace("'","''",$bdesc);
  86. $result = mysqli_query($conn, "INSERT INTO blog(bname,bimage,btitle,bdesc) VALUES('$bname','$bimage','$btitle','$bdesc')");
  87. if ($result)
  88. {
  89. //display success message
  90. echo "<font color='green'>Data added successfully.";
  91. echo "<br/><a href='add1.php'>View Result</a>";
  92. }
  93. else
  94. {
  95. echo mysqli_error($conn);
  96. if ($conn) echo "no data base";
  97. }
  98. }
  99.  
  100. ?>
  101. </body>
  102. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement