开发者

record deleted when link is clicked

开发者 https://www.devze.com 2023-02-21 18:13 出处:网络
I have a link/page \'myfiles.php\' which shows the details of the file that a certain user uploaded. But after clicking again/entering the \'myfiles.php\' into the address bar, the records are gone in

I have a link/page 'myfiles.php' which shows the details of the file that a certain user uploaded. But after clicking again/entering the 'myfiles.php' into the address bar, the records are gone in the page. What's supposed to be the solution? Please help. Thanks. Here's my code:

while ($row=mysql_fetch_array($query)) {

    $row1 = $row['name'];
    $row2 = $row['size'];
    $row3 = $row['type'];
    $delfile =开发者_如何学Python "<a href='deletefile.php?file=$row1'>Delete file</a>";
    $dlfile = "<a href='download.php?file=$row1'>Download</a> ";
    echo "<p>";
    echo $row1;
    echo "<br>";
    echo $row2;
    echo "<br>";
    echo $row3;
    echo "<br>";
    echo $dlfile;
    echo $delfile; 
}


Are you using some sort of browsing accelerator and don´t you have a deletion confirmation?

It seems your browser is requesting all links on your page and deleting your records.

If you want to delete, insert, update, etc. records in a database, it is a very good idea to use POST instead of GET (like a clickable link), so you would have to add a form around every entry that posts the data to the server. You can of course skip this, but then you definitely need a POST based deletion confirmation.


I am assuming that $usersess is not changing? If this is dependent on a session or cookie - you should check that it is not expiring or being destroyed.

$query = mysql_query("SELECT * FROM uploadedfiles WHERE username='$usersess' ");
while ($row = mysql_fetch_array($query)) {

  $delfile = "<a href=\"deletefile.php?file={$row['name']}\">Delete file</a>";
  $dlfile = "<a href=\"download.php?file={$row['name']}\">Download</a> ";

  echo "<p>{$row['name']}<br>
        {$row['size']}<br>
        {$row['type']}<br>
        {$dlfile}{$delfile}</p>";
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号