Hallo Rainer,
etwas "futter" zum experimentieren (aus meinem "hallo-welt-fundus *G*). Das ist so ungefähr der minimalaufwand, um eine ganz rudimentäre "txt-verwaltung" aufzubauen. Und nicht vergessen: chmod 777 auf das txt-verzeichnis, sonst gibt's mecker vom server ;)
---snip---
*** FILEDEMO.HTM:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>FILE-DEMO</title>
</head>
<body>
<h3>FILE-DEMO</h3>
<a href="file.php3?CMD=list">liste...</a><br>
<a href="file.php3?CMD=new">neu...</a><br>
<a href="file.php3?CMD=edit">bearbeiten...</a><br>
<a href="file.php3?CMD=del">löschen...</a><br>
</body>
</html>
*** FILE.PHP
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>FILE-DEMO</title>
</head>
<body>
<a href="filedemo.htm">MENU...</a>
<br><br>
<?php
$basedir= "/website/htdocs/lab/php3/file/";
//$basedir= "/home/www/wowbagger/lab/php/file/";
$wildcard= "^demo[0-9]+.txt$";
function cmd_list($sub_cmd) {
$fstr= $GLOBALS["basedir"].".";
$handle= opendir($fstr);
while ($entry= readdir($handle)) {
if (!is_dir($entry) && eregi($GLOBALS["wildcard"], $entry)) {
if ($sub_cmd=="del") {
$reg= eregi("[0-9]+", $entry, $regs);
echo "<a href='file_act.php3?CMD=del&SUB_CMD=". $regs[0] ."'>";
}
if ($sub_cmd=="edit") {
$reg= eregi("[0-9]+", $entry, $regs);
echo "<a href='file_act.php3?CMD=edit&SUB_CMD=". $regs[0] ."'>";
}
echo $entry."<br>";
if ($sub_cmd=="del" $sub_cmd=="edit") echo "</a>";
}
}
closedir($handle);
}
switch ($CMD) {
case "new": //********** NEW
?>
<form name="form" action="file_act.php3?CMD=new" method="POST">
INHALT:<br>
<textarea name="content" cols="50" rows="10"></textarea>
<br>FILE_ID:
<select name="file_ID">
<?php
for ($i=1;$i<11;$i++) {
echo "<option value='". $i . "'>". $i;
}
?>
</select>
<br><br>
<input type="submit" value="abschicken">
</form>
<?php
break;
case "list": //********** LIST
cmd_list("list");
break;
case "del": //********** DELETE
cmd_list("del");
break;
case "edit": //********** EDIT
cmd_list("edit");
break;
}
?>
</body>
</html>
*** FILE_ACT.PHP
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>FILE-DEMO</title>
</head>
<body>
<a href="filedemo.htm">MENU...</a>
<br><br>
<?php
$basedir= "/website/htdocs/lab/php3/file/";
//$basedir= "/home/www/wowbagger/lab/php/file/";
switch ($CMD) {
case "new": //********** NEW
$fstr= $basedir."demo".$file_ID.".txt";
$handle= fopen($fstr, "w");
fputs($handle, $content);
fclose($handle);
break;
case "del": //********** DELETE
$fstr= $basedir."demo".$SUB_CMD.".txt";
unlink($fstr);
break;
case "edit": //********** EDIT
$fstr= $basedir."demo".$SUB_CMD.".txt";
$handle= fopen($fstr, "r");
$content= fread($handle, filesize($fstr));
fclose($handle);
echo "<form name='form' action='file_act_sub.php3?CMD=edit&SUB_CMD=". $SUB_CMD. "' method='POST'>";
?>
INHALT:<br>
<textarea name="content" cols="50" rows="10">
<?php
echo $content;
?>
</textarea>
<br><br>
<input type="submit" value="abschicken">
</form>
<?php
break;
}
?>
</body>
</html>
*** FILE_ACT_SUB.PHP
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>FILE-DEMO</title>
</head>
<body>
<a href="filedemo.htm">MENU...</a>
<br><br>
<?php
$basedir= "/website/htdocs/lab/php3/file/";
//$basedir= "/home/www/wowbagger/lab/php/file/";
switch ($CMD) {
case "edit": //********** EDIT
$fstr= $basedir."demo".$SUB_CMD.".txt";
$handle= fopen($fstr, "w");
fputs($handle, $content);
fclose($handle);
break;
}
?>
</body>
</html>
---snap---
Bis denn...
/*,*/
Wowbagger