Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once('../config.php');
- session_start();
- if (!isset($_SESSION['loggedIn']))
- {
- header('Location: login.php');
- exit;
- }
- //if there is clicked on the delete button, get id and select al media equal to id
- if (isset($_GET['delete']))
- {
- $delete_id = $_GET['delete'];
- $query = "SELECT * FROM media1 WHERE project_project_id = '$delete_id'";
- //run multiple query
- $result = mysqli_query($db, $insertQuery);
- //check if media exist than delete from folder
- while($row = mysqli_fetch_assoc($result))
- {
- $post_media = $row ['media_image'];
- $path = "../img/project_img";
- if(file_exists($path."/".$post_media))
- {
- unlink($path."/".$post_media);
- }
- }
- //delete all things equal tot id
- $emptyQuery = "DELETE project1, media1, tags1 FROM project1
- JOIN tags1 ON project_id = tags1.project_project_id
- JOIN media1 ON project_id = media1.project_project_id
- WHERE project_id = $delete_id";
- if(mysqli_query($db, $emptyQuery))
- {
- echo "<script> alert('Je hebt het project succesvol verwijderd')</script>";
- echo "<script>window.open('overview_work.php','_self');</script>";
- }
- //close database
- mysqli_close($db);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement