I have a problem in delete item. My problem is when I click on delete the button the item does not disappear but when I refresh it it does disappear.
And this is my code :
index.php
<?php
    $config = mysql_connect("localhost", "root", "") or die (mysql_error());
    $db = mysql_select_db("darith_upload_img",$config) or die (mysql_error());
?>
<!DOCTYPE HTML>
<html>
    <head></head>
<body>
        <form action="upload_process.php" enctype="multipart/form-data" method="POST">
            <input type="file" name="img" /><br />
            <input type="submit" value="upload Now" />
        </form>
        <?php
            $result = mysql_query("SELECT * FROM table_img");
            while($row = mysql_fetch_array($result))
            {
            $id = $row['id_img'];
                ?>
            <table border="1">
                    <tr>
                        <td><?php echo $row['id_img']; ?></td>
                        <td width="200" ><?php echo $row['location_img']; ?></td>
                        <td><?php echo '<img src="' . $row['location_img'] . '" width="60"/>'; ?></td>
                        <td><a href="index.php?id=<?php echo $id;?> " onClick="return confirm('Are you sure?')">Delete</a></td>
                    </tr>
                </table>
        <?php
            }
        ?>
        <?php
            if(isset($_GET['id'])){
                $id_img=$_GET['id'];
                $q_del=mysql_query("DELETE FROM table_img where id_img ='$id_img'");
                header("Location: http://example.com/path/to/index.php");
            }
        ?>
</body>
</html>
upload_process.php
<?php
    $config = mysql_connect("localhost", "root", "") or die (mysql_error());
    $db = mysql_select_db("darith_upload_img", $config) or die (mysql_error());
    if(isset($_FILES["img"]["tmp_name"]))
    {
        move_uploaded_file($_FILES["img"]["tmp_name"], "picture/". $_FILES["img"]["name"]);
        $location = "picture/".$_FILES["img"]["name"];
    $save = mysql_query("INSERT INTO table_img (location_img) VALUES ('$location')");
    header("Location: http://example.com/path/to/index.php");
    }
    exit();
?>
 
     
     
     
     
    