Annonceindlæg fra Computerworld it-jobbank
16. februar 2004 - 11:27
#1
Her er et forslag ######## <?php function nyKomm($navn, $email, $overskrift, $kommentar){ $filnavn="minfil.txt"; $fp = fopen ($filnavn, "r") or die("Er $filnavn til stede");//Opretter filen hvis den ikke eksisterer while (!feof($fp)){ $gammel = $gammel.fgets ($fp, 4096); }//while slut if (strlen(date('j')) < 2 ){ $dag = "0". date('j'); }else{ $dag = date('j'); } if (strlen(date('n')) < 2 ){ $maaned = "0". date('n'); }else{ $dag = date('n'); } $dato = $dag . '/' . date('n') . '/' . date('Y'); $nyKommentar = $dato."¤".$navn."¤".$email."¤".$overskrift."¤".$kommentar."¤<indlaeg>"; $ny = $nyKommentar.$gammel; fclose ($fp); $fp = fopen ($filnavn, "w") or die("Er $filnavn til stede");//Opretter filen hvis den ikke eksisterer fwrite ($fp, $ny); }// slut nyKomm() function visGaestebog(){ $filnavn="minfil.txt"; $fp = fopen ($filnavn, "r") or die("Er $filnavn til stede");//Opretter filen hvis den ikke eksisterer while (!feof($fp)){ $nyStreng = $nyStreng.fgets($fp, 4096); }//while slut $nytArray = explode("<indlaeg>", $nyStreng); $a = count($nytArray); $i = 0; ?> <table width="800" border="0" cellpadding="0" cellspacing="0" align="left"> <tr > <td width="20" height="20"> </td> <td width="350" bgcolor="#999966" > <div align="center"><font face="Verdana, Arial, Helvetica, sans-serif"><font size="1"><b>[ gæstebog ]</b></font></font></div> </td> <td width="20" bgcolor="#999966"> </td> <td bgcolor="#999966" width="400" bgcolor="#999966"> <div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"> <b>[ giv din mening ]</b></font></div> </td> </tr> <tr> <td></td><td> </td> <td></td><td rowspan="20" align="center" valign="top"><br><br><form action="gaestebog.php" name="kommentar" onSubmit="valid()" method="get"> <table width="300" height="300" border="0" cellpadding="0" cellspacing="0" align="left"> <tr> <tr valign="top"><td></td> <td style="font-size:12; font-weight:bold"><center> Skriv din mening ris/ros om fredagsbar.dk</center></td> </tr> <tr valign="top"> <td style="font-size:12">Navn:</td> <td><input type="text" maxlength="40" size="40" name="navn" style="background-color:#999966; border:none"></td></tr> <tr valign="top"> <td style="font-size:12">Email:</td> <td><input type="text" maxlength="40" size="40" name="email" style="background-color:#999966; border:none"></td></tr> <tr valign="top"> <td style="font-size:12">Overskrift:</td> <td><input type="text" maxlength="40" size="40" name="overskrift" style="background-color:#999966; border:none"></td></tr> <tr valign="top"> <td style="font-size:12">Kommentar:</td> <td><textarea name="kommentar" cols="40" rows="10" wrap="soft" style="background-color:#999966; font-family: Verdana, Arial, Helvetica, sans-serif; font-size:12; border:none "></textarea></td></tr> <tr valign="top"><td></td><td align="center"><input type="submit" value="Send" name="send" onFocus="blur()" style="background-color:#999966; border:none; font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold "> <input type="reset" value="Slet alt" onFocus="blur()"style="background-color:#999966; border:none; font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold"></td></tr> </table> </form></td> </tr> <tr><td></td><td align="center"><br><br><img src="gfx/skriv.gif"></td></tr> <? echo $a; while ($i <= $a-2){ $nyt = explode("¤", $nytArray[$i]); echo ("<tr><td></td><td style='border:1px;font-family: Verdana, Arial, Helvetica, sans-serif;font-size:10 '>".$nyt[0]."</td></tr>");//dato echo ("<tr><td></td><td style='border:none;font-family: Verdana, Arial, Helvetica, sans-serif;font-size:12'>".$nyt[1]."(<a href='mailto:".$nyt[2]."' onFocus='blur()'><i>$nyt[2]</i></a>)</td></tr>");//navn echo ("<tr><td></td><td style='border:none;font-family: Verdana, Arial, Helvetica, sans-serif; font-size:12; font-weight:bold;text-decoration: underline'>".$nyt[3]."</td></tr>");//Overskrift echo ("<tr><td></td><td><textarea readonly='readonly' style='background-color: #cccc98;border:none;font-family: Verdana, Arial, Helvetica, sans-serif;font-size:12 'cols=60 rows=5 wrap=soft>".$nyt[4]."</textarea></td></tr>");//Kommentar echo ("<tr><td></td><td><hr></td></tr>");//Streg $i++; } ?></table><? }// slut visGaestebog() function visForm(){ ?> <form action="gaestebog.php?tilfoj=true" name="kommentar" onSubmit="valid()" method="get"> <table width="800" border="0" cellpadding="0" cellspacing="0" align="left"> <tr> <td width="20" bgcolor="#999966"> </td> <td width="350" bgcolor="#999966"> <div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><font size="1"><b>[ gæstebog ]</b></font></font></div> </td> <td width="20" bgcolor="#999966"> </td> <td bgcolor="#999966" width="400" bgcolor="#999966"><div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b>[ ugens fredagsbarn ]</b></font></div></td> </tr> <tr> <td></td> <td><a href='gaestebog.php'>Vis gæstebogen </a></td> </tr> <tr valign="top"> <td style="">Navn:</td> <td><input type="text" maxlength="40" size="20" name="navn"></td></tr> <tr valign="top"><td>Email:</td><td><input type="text" maxlength="40" size="20" name="email"></td></tr> <tr valign="top"><td>Overskrift:</td><td><input type="text" maxlength="40" size="20" name="overskrift"></td></tr> <tr valign="top"><td>Kommentar:</td><td><textarea name="kommentar" cols="40" rows="10" wrap="soft"></textarea></td></tr> <tr valign="top"><td></td><td><input type="submit" value="Send" name="send"><input type="reset" value="Slet alt"></td></tr> </table> </form> <? } ?> <style> td{ border:none; font-family: Verdana, Arial, Helvetica, sans-serif; font-size:10; } body{ SCROLLBAR-ARROW-COLOR: #979763; SCROLLBAR-TRACK-COLOR: #979763; SCROLLBAR-BASE-COLOR: #CCCC98; scrollbar-darkshadow-color: #979763; scrollbar-3dlight-color:#979763; scrollbar-highlight-color:none; form-BASE-COLOR: #CCCC98; } </style><html> <head> <title></title> </head> <body bgcolor="#CCCC98" text="#000000" link="#FFFFFF" vlink="#ffffff" alink="#000000" bgproperties="fixed" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="" background="gfx/background.jpg"> <? if ($send == "Send"){ nyKomm($navn, $email, $overskrift, $kommentar); } visGaestebog(); ?> </body> </html>
16. februar 2004 - 11:42
#2
danny_k Det ser ikke helt dumt ud, men jeg har ikke adgang til at skrive i filen på serveren. ---- Warning: fopen("minfil.txt","w") - Permission denied in /gaestebog.php on line 23 Er minfil.txt til stede ---- Ved du hvordan alle kan få adgang til at skrive i minfil.txt på serveren?