iuliaa

Untitled

Dec 12th, 2020
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.81 KB | None | 0 0
  1. <?php
  2.  
  3. if(isset($_POST['upload'])){
  4. $target="images/".basename($_FILES['image']['name']);
  5. $db = mysqli_connect("localhost","root","","sfdatabase");
  6. $image=$_FILES['image']['name'];
  7. $title=$_POST['title'];
  8. $text=$_POST['text'];
  9. $sql="INSERT INTO destinations_page (destination,image,description) VALUES ('$title','$image','$text')";
  10. mysqli_query($db,$sql);
  11.  
  12. if(move_uploaded_file($_FILES['image']['tmp_name'], $target)){
  13. $msg="Uploaded successfully";
  14. }else{
  15. $msg="Couldn't upload";
  16. }
  17.  
  18. }
  19.  
  20. ?>
  21.  
  22. <!DOCTYPE html>
  23. <html>
  24. <head>
  25. <link rel="stylesheet" href="styles.css">
  26. <link rel="stylesheet" href="paragraphs_styles.css">
  27. <link href="https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@300;400;700&display=swap" rel="stylesheet">
  28. <script src="https://kit.fontawesome.com/b28a5ee64c.js" crossorigin="anonymous"></script>
  29. <style>
  30. #buttonsubmit{
  31. background-color:inherit;
  32. border: 2px solid white;
  33. font-family: 'Roboto Condensed', sans-serif;
  34. font-size:15px;
  35. cursor: pointer;
  36. height: 50px;
  37. width: 90px;
  38. }
  39.  
  40. </style>
  41. </head>
  42. <title>Safe Flight</title>
  43. <header>
  44. <div id="wrap">
  45. <img src="images/plane_logo.png" height=125px>
  46. <img src="images/text_logo.png" height=125px>
  47. </div>
  48. </header>
  49. <body>
  50.  
  51. <div class="menu">
  52. <nav>
  53. <ul>
  54. <li><a href="admin_index.php"> Home </a></li>
  55. <li><a href="#flights"> Flights and Reservations <i class="fas fa-caret-down"></i> </a>
  56. <ul>
  57. <li><a href="admin_book.php"> Book a Flight </a></li>
  58.  
  59. <li><a href="admin_destinations.php"> Destinations </a></li>
  60. <li><a href="admin_splflights.php"> Special Flights and Offers </a></li>
  61. </ul>
  62. </li>
  63. <li><a href="#info"> Useful Information <i class="fas fa-caret-down"></i> </a>
  64. <ul>
  65. <li><a href="admin_luggage.php"> Luggage </a></li>
  66. <li><a href="admin_facilities.php"> Flight Facilities </a></li>
  67. <li><a href="admin_bflight.php"> Business Flights </a></li>
  68. <li><a href="admin_eflight.php"> Economy Flights </a></li>
  69. <li><a href="admin_companies.php"> Information for Companies </a></li>
  70. </ul>
  71. </li>
  72.  
  73. <li><a href="index.html?logout='1'"> Logout </a>
  74. </li>
  75. </ul>
  76. </nav>
  77. </div>
  78.  
  79. <div class="luggage_container">
  80. <img src="images/globe.png" width="1200px">
  81. <div class="textoverlay">
  82. <h1> Destinations</h1>
  83. </div>
  84. </div>
  85.  
  86. <div id="insert_form">
  87. <!--print from db-->
  88. <?php
  89. $db=mysqli_connect("localhost","root","","sfdatabase");
  90. $sql = "SELECT * FROM destinations_page";
  91. $result=mysqli_query($db,$sql);
  92. while($row=mysqli_fetch_array($result)){
  93. echo "<div class='dest'>";
  94. echo "<div class='paragraphs'>";
  95. echo "<h2>".$row['destination']."</h2>";
  96. echo "<img src='images/".$row['image']."'>";
  97. echo "<p>".$row['description']."</p>";
  98. echo "</div>";
  99. echo "</div>";
  100. }
  101. ?>
  102. <h2> Add a new destination </h2>
  103. <form method="post" action="admin_destinations.php" enctype="multipart/form-data" id="add">
  104. <input type="hidden" name="size" value="1000000">
  105. <div>
  106. <input type="file" name="image">
  107. </div>
  108. <div>
  109. <textarea name="title" cols="40" rows="5" placeholder="Add a destination name."></textarea>
  110. </div>
  111. <div>
  112. <textarea name="text" cols="40" rows="5" placeholder="Add a description."></textarea>
  113. </div>
  114. <div>
  115. <input type="submit" name="upload" value="Upload text" id="buttonsubmit">
  116. </div>
  117. </form>
  118. </div>
  119. <!--modify-->
  120. <div class="form">
  121. <h2>View Records</h2>
  122. <table width="100%" border="1" style="border-collapse:collapse;">
  123. <thead>
  124. <tr>
  125. <th><strong>ID</strong></th>
  126. <th><strong>Destination</strong></th>
  127. <th><strong>Image</strong></th>
  128. <th><strong>Description</strong></th>
  129. <th><strong>Edit</strong></th>
  130. <th><strong>Delete</strong></th>
  131. </tr>
  132. </thead>
  133. <tbody>
  134. <?php
  135. $count=1;
  136. $db=mysqli_connect("localhost","root","","sfdatabase");
  137. $sel_query="Select * from destinations_page ORDER BY id asc;";
  138. $result = mysqli_query($db,$sel_query);
  139. while($row = mysqli_fetch_assoc($result)) { ?>
  140. <tr><td align="center"><?php echo $count; ?></td>
  141. <td align="center"><?php echo $row["destination"]; ?></td>
  142. <td align="center"><?php echo $row["image"]; ?></td>
  143. <td align="center"><?php echo $row["description"]; ?></td>
  144. <td align="center">
  145. <a href="edit_destinations.php?id=<?php echo $row["id"]; ?>">Edit</a>
  146. </td>
  147. <td align="center">
  148. <a href="delete_destinations.php?id=<?php echo $row["id"]; ?>">Delete</a>
  149. </td>
  150. </tr>
  151. <?php $count++; } ?>
  152. </tbody>
  153. </table>
  154. </div>
  155. </body>
  156. </html>
Advertisement
Add Comment
Please, Sign In to add comment