Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['upload'])){
- $target="images/".basename($_FILES['image']['name']);
- $db = mysqli_connect("localhost","root","","sfdatabase");
- $image=$_FILES['image']['name'];
- $title=$_POST['title'];
- $text=$_POST['text'];
- $sql="INSERT INTO destinations_page (destination,image,description) VALUES ('$title','$image','$text')";
- mysqli_query($db,$sql);
- if(move_uploaded_file($_FILES['image']['tmp_name'], $target)){
- $msg="Uploaded successfully";
- }else{
- $msg="Couldn't upload";
- }
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <link rel="stylesheet" href="styles.css">
- <link rel="stylesheet" href="paragraphs_styles.css">
- <link href="https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@300;400;700&display=swap" rel="stylesheet">
- <script src="https://kit.fontawesome.com/b28a5ee64c.js" crossorigin="anonymous"></script>
- <style>
- #buttonsubmit{
- background-color:inherit;
- border: 2px solid white;
- font-family: 'Roboto Condensed', sans-serif;
- font-size:15px;
- cursor: pointer;
- height: 50px;
- width: 90px;
- }
- </style>
- </head>
- <title>Safe Flight</title>
- <header>
- <div id="wrap">
- <img src="images/plane_logo.png" height=125px>
- <img src="images/text_logo.png" height=125px>
- </div>
- </header>
- <body>
- <div class="menu">
- <nav>
- <ul>
- <li><a href="admin_index.php"> Home </a></li>
- <li><a href="#flights"> Flights and Reservations <i class="fas fa-caret-down"></i> </a>
- <ul>
- <li><a href="admin_book.php"> Book a Flight </a></li>
- <li><a href="admin_destinations.php"> Destinations </a></li>
- <li><a href="admin_splflights.php"> Special Flights and Offers </a></li>
- </ul>
- </li>
- <li><a href="#info"> Useful Information <i class="fas fa-caret-down"></i> </a>
- <ul>
- <li><a href="admin_luggage.php"> Luggage </a></li>
- <li><a href="admin_facilities.php"> Flight Facilities </a></li>
- <li><a href="admin_bflight.php"> Business Flights </a></li>
- <li><a href="admin_eflight.php"> Economy Flights </a></li>
- <li><a href="admin_companies.php"> Information for Companies </a></li>
- </ul>
- </li>
- <li><a href="index.html?logout='1'"> Logout </a>
- </li>
- </ul>
- </nav>
- </div>
- <div class="luggage_container">
- <img src="images/globe.png" width="1200px">
- <div class="textoverlay">
- <h1> Destinations</h1>
- </div>
- </div>
- <div id="insert_form">
- <!--print from db-->
- <?php
- $db=mysqli_connect("localhost","root","","sfdatabase");
- $sql = "SELECT * FROM destinations_page";
- $result=mysqli_query($db,$sql);
- while($row=mysqli_fetch_array($result)){
- echo "<div class='dest'>";
- echo "<div class='paragraphs'>";
- echo "<h2>".$row['destination']."</h2>";
- echo "<img src='images/".$row['image']."'>";
- echo "<p>".$row['description']."</p>";
- echo "</div>";
- echo "</div>";
- }
- ?>
- <h2> Add a new destination </h2>
- <form method="post" action="admin_destinations.php" enctype="multipart/form-data" id="add">
- <input type="hidden" name="size" value="1000000">
- <div>
- <input type="file" name="image">
- </div>
- <div>
- <textarea name="title" cols="40" rows="5" placeholder="Add a destination name."></textarea>
- </div>
- <div>
- <textarea name="text" cols="40" rows="5" placeholder="Add a description."></textarea>
- </div>
- <div>
- <input type="submit" name="upload" value="Upload text" id="buttonsubmit">
- </div>
- </form>
- </div>
- <!--modify-->
- <div class="form">
- <h2>View Records</h2>
- <table width="100%" border="1" style="border-collapse:collapse;">
- <thead>
- <tr>
- <th><strong>ID</strong></th>
- <th><strong>Destination</strong></th>
- <th><strong>Image</strong></th>
- <th><strong>Description</strong></th>
- <th><strong>Edit</strong></th>
- <th><strong>Delete</strong></th>
- </tr>
- </thead>
- <tbody>
- <?php
- $count=1;
- $db=mysqli_connect("localhost","root","","sfdatabase");
- $sel_query="Select * from destinations_page ORDER BY id asc;";
- $result = mysqli_query($db,$sel_query);
- while($row = mysqli_fetch_assoc($result)) { ?>
- <tr><td align="center"><?php echo $count; ?></td>
- <td align="center"><?php echo $row["destination"]; ?></td>
- <td align="center"><?php echo $row["image"]; ?></td>
- <td align="center"><?php echo $row["description"]; ?></td>
- <td align="center">
- <a href="edit_destinations.php?id=<?php echo $row["id"]; ?>">Edit</a>
- </td>
- <td align="center">
- <a href="delete_destinations.php?id=<?php echo $row["id"]; ?>">Delete</a>
- </td>
- </tr>
- <?php $count++; } ?>
- </tbody>
- </table>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment