12219
May 02, 2005, updated at May 22, 2005 (UTC)
3377
1
0
merkwürdige leerzeile bei txt datei
hi
folgene scripts:
wenn ich bei der administration den jeweils letzten eintrag lösche entsteht eine leerzeile wenn der nächste sich anmeldet.
wenn ich einen in der mitte lösche jedoch nicht
wo liegt der fehler?
folgene scripts:
Das formular anmelden.php
<html>
<head>
<style type="text/css">
body, textarea {
scrollbar-base-color:#7A89C1;
scrollbar-3dlight-color:#2B3869;
scrollbar-arrow-color:#FF9900;
scrollbar-darkshadow-color:#000000;
scrollbar-face-color:#2B3869;
scrollbar-highlight-color:#7A89C1;
scrollbar-shadow-color:#2B3869;
scrollbar-track-color:#2B3869;
}
</style>
</head>
<body bgcolor="#42518C" text="white" link="orange" vlink="orange" alink="#808080" >
<table align="center" cellpadding="10">
<th align="center" bgcolor="#3C4B81"><h1 style="color:orange">ANMELDEN</h1></th>
<tr bgcolor="#596BB1" >
<td>
<FORM ACTION="anmeldung.php" METHOD=POST>
<INPUT TYPE=HIDDEN NAME=id VALUE=17862>
<table border="0" cellpadding="5" cellspacing="0" >
<tr>
<td align="right">Betreff:</td>
<td><input name="betreff" type="text" size="30" value="<?php echo "$betreff"; ?>" readonly></td>
</tr> <tr>
<td align="right">Name:</td>
<td><input name="name" type="text" size="30" maxlength="30"></td>
</tr><tr>
<td align="right">Email:</td>
<td><input name="email" type="text" size="30" maxlength="40"></td>
</tr><tr>
<td align="right" valign="top">Kommentar:</td>
<td><textarea name="text" rows="10" cols="30"></textarea></td>
</tr><tr>
<td align="right">Formular:</td>
<td>
<input type="submit" value=" Absenden ">
<input type="reset" value=" Abbrechen">
</td>
</tr>
</table>
</form>
</td>
</tr>
<tr bgcolor="#3C4B81" >
<td>
<center>
Werdet ihr zugelassen, erhaltet ihr eine Einladung vom Organisator.
</center>
</td>
</tr>
</body>
</html>
Das auswertende Script anmeldung.php
<html>
<head>
<style type="text/css">
body, textarea {
scrollbar-base-color:#7A89C1;
scrollbar-3dlight-color:#2B3869;
scrollbar-arrow-color:#FF9900;
scrollbar-darkshadow-color:#000000;
scrollbar-face-color:#2B3869;
scrollbar-highlight-color:#7A89C1;
scrollbar-shadow-color:#2B3869;
scrollbar-track-color:#2B3869;
}
</style>
</head>
<body bgcolor="#42518C" text="white" link="orange" vlink="orange" alink="#808080" >
<table align="center" cellpadding="10">
<th align="center" bgcolor="#3C4B81"><h1 style="color:orange">ANMELDEN</h1></th>
<tr bgcolor="#596BB1" >
<td>
<table border="0" cellpadding="5" cellspacing="0" >
<tr>
<td>
<?php
$fp = fopen("anmeldungen.txt","a");
if ($fp)
{
flock($fp,2);
$nl = chr(13) . chr(10);
fputs ($fp, "$nl $betreff;$name;$email;$text");
echo "Vielen Dank, $name
</br>";
echo "Folgende Angaben wurden gespeichert:
";
echo "Name: $name
";
echo "Email: $email
";
echo "Kommentar: $text
";
flock($fp,3);
fclose($fp);
}
else
{
echo "Datei konnte nicht zum";
echo " Schreiben geöffnet werden";
}
?>
</td>
</tr>
</table>
</form>
</td>
</tr>
<tr bgcolor="#3C4B81" >
<td>
<center>
<input type="button" name="Verweis" value="zurück"
onClick="self.location.href='lan.html'">
</center>
</td>
</tr>
</body>
</html>
und das administrationsscript
adminanm.php
<html>
<head>
<style type="text/css">
body, textarea {
scrollbar-base-color:#7A89C1;
scrollbar-3dlight-color:#2B3869;
scrollbar-arrow-color:#FF9900;
scrollbar-darkshadow-color:#000000;
scrollbar-face-color:#2B3869;
scrollbar-highlight-color:#7A89C1;
scrollbar-shadow-color:#2B3869;
scrollbar-track-color:#2B3869;
}
</style>
</head>
<body bgcolor="#42518C" text="white" link="orange" vlink="orange" alink="#808080" >
<table align="center" cellpadding="10">
<th align="center" bgcolor="#3C4B81"><h1 style="color:orange">ANMELDUNGEN</h1></th>
<tr bgcolor="#596BB1" >
<td>
<table border="1" cellpadding="5" cellspacing="0" >
<th>Nummer</th> <th>Betreff</th> <th>Name</th> <th>Email</th> <th>Text</th>
<?php
$fp = fopen("anmeldungen.txt","r");
if ($fp)
{
while (!feof($fp))
{
$zeile = fgets($fp, 100);
$datei = $datei .",". $zeile ;
}
fclose($fp);
}
else
echo "Datei wurde nicht gefunden";
$fp = fopen("anmeldungen.txt","w");
if ($fp)
{
flock($fp,2);
$nl = chr(13) . chr(10);
$satze = explode(",",$datei);
$pos = sizeof($satze);
for($i=0; $i<$pos; $i++)
{
if($i!=$aim)
{
fputs ($fp,"$satze[$i]");
}
}
flock($fp,3);
fclose($fp);
}
else
{
echo "Datei konnte nicht zum";
echo " Schreiben geöffnet werden";
}
$fp = fopen("anmeldungen.txt","r");
if ($fp)
{
while (!feof($fp))
{
$zeile = fgets($fp, 100);
$zeile = str_replace(";","</td><td>",$zeile);
$nummer= $nummer+1;
echo "<tr><td>$nummer</td><td> $zeile </td></tr>";
}
fclose($fp);
}
else
echo "Datei wurde nicht gefunden";
?>
</table>
<form action="adminanm.php" method="post">
<input type="text" size="3" maxlength="3" name="aim">
<input type="submit" value="Löschen">
</form>
</td>
</tr>
<tr bgcolor="#3C4B81" >
<td>
<center>
<input type="button" name="Verweis" value="zurück"
onClick="self.location.href='lan.html'">
</center>
</td>
</tr>
</body>
</html>
wenn ich bei der administration den jeweils letzten eintrag lösche entsteht eine leerzeile wenn der nächste sich anmeldet.
wenn ich einen in der mitte lösche jedoch nicht
wo liegt der fehler?
Please also mark the comments that contributed to the solution of the article
Content-Key: 10212
Url: https://administrator.de/contentid/10212
Printed on: April 24, 2024 at 09:04 o'clock
1 Comment