Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][HTML]wracanie do strony po wykonaniu komendy - jak?
Luki2604
post
Post #1





Grupa: Zarejestrowani
Postów: 16
Pomógł: 0
Dołączył: 17.01.2007

Ostrzeżenie: (0%)
-----


hej, mam taki skrypcik, pobiera liste plikow z folderu i umozliwia ich kasowanie. Chcialbym, aby po wcisnieciu "USUN" przegladarka uruchamiala na nowo plik .php bez zadnych komend na koncu - teraz zostawia: "http://.../files.php?deleteFile=CKK-%2012813" potrzebne mi to jest aby przegladarka mogla odswierzac zawartosc okna automatycznie co klika sekund lub poprzez F5. Moglby ktos pomoc ? Pozdrawiam !
skrypt:
  1. <?php
  2. function dirList ($directory)
  3. {
  4.  
  5.    // create an array to hold directory list
  6.    $results = array();
  7.  
  8.    // create a handler for the directory
  9.    $handler = opendir($directory);
  10.  
  11.    // keep going until all files in directory have been read
  12.    while ($file = readdir($handler)) {
  13.  
  14.        // if $file isn't this directory or its parent,
  15.        // add it to the results array
  16.  
  17.        if ($file != '.' && $file != '..' && is_file($directory."/".$file) == TRUE)
  18.            $results[] = $file;
  19.    }
  20.  
  21.    // tidy up: close the handler
  22.    closedir($handler);
  23.  
  24.    // done!
  25.    return $results;
  26. }
  27.  
  28. header('Content-type: text/html; charset=utf-8'); //musi byc bo rozne serwery sa z roznym kodowaniem
  29.  
  30. //<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  31. $html = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">';
  32. $html .= '<html>';
  33. $html .= '<head>';
  34. $html .= '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
  35. $html .= '<title>';
  36. $html .= "Pliki";
  37. $html .= '</title>';
  38. $html .= '</head>';
  39. $html .= '<body>';
  40. $html .= "<div>";
  41.  
  42. $aDir = "./myfiles";
  43.  
  44. $files = dirList($aDir);
  45.  
  46. if (TRUE == array_key_exists("deleteFile", $_GET))
  47.  {
  48.  $file = $aDir."/".$_GET["deleteFile"];
  49.  if ($file == $_SERVER["SCRIPT_NAME"])
  50.    {
  51.    $html .= "Nie mozna usunac tego pliku<br>";
  52.    }
  53.    else if (file_exists($file) && unlink($file))
  54.    {
  55.    $html .= "Usunieto $file<br>";
  56.    }
  57.  else
  58.    {
  59.    $html .= "Blad podczas usuwania pliku $file<br>";
  60.    }
  61.  }
  62. foreach ($files as $val)
  63.  {
  64.  $html .= "$val - <a href=\"?deleteFile=$val\">Usun</a><br>";
  65.  }
  66.  
  67. $html .= "</div>";
  68. $html .= '</body>';
  69. $html .= '</html>';
  70.  
  71. echo $html;
  72. ?>


Ten post edytował Spawnm 7.07.2009, 14:15:24
Powód edycji: [Spawnm] Proszę używać bbcode.
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 24.12.2025 - 14:48