Hi i made myself a little news system with a *.txt DB problem is im trying to get the last entry to show in the front page of my website, and the rest of the entries mus’nt be show… how a im to do this…
here is the script:
<?
if($HTTP_POST_VARS['submit']) {
if($HTTP_POST_VARS['password'] == 'test') { //* verander passwoord *//
if(!$HTTP_POST_VARS['image']) {
}
if(!$HTTP_POST_VARS['news']) {
echo "<font class=\"error_tekst\">Er is geen nieuws item in gevoert.. vooer deze in a.u.b..</font><form><input type=\"button\" value=\"Terug\" onClick=\"javascript: history.go(-1)\"></form><br>";
exit;
}
if(strstr($HTTP_POST_VARS['news'],"|")) {
echo "<font class=\"error_tekst\">Er is een ongeldig symbool gevonden.. verwijder de \"|\".. a.u.b.. (klik op de terug knop) a.u.b..</font><form><input type=\"button\" value=\"Terug\" onClick=\"javascript: history.go(-1)\"></form><br>";
exit;
}
if(strstr($HTTP_POST_VARS['news'],"<")) {
echo "<font class=\"error_tekst\">Er er is een HTML TAG Teken aan getroffel.. wij hebben gelieve niet dat u deze codes gebruikt.. verwijder deze a.u.b...</font><form><input type=\"button\" value=\"Terug\" onClick=\"javascript: history.go(-1)\"></form><br>";
exit;
}
$fp = fopen('news.txt','a');
if(!$fp) {
echo "<font class=\"error_tekst\">Error.. kan het bestand niet openen.. controleer of \"news.txt\" het aanwezig is..</font><form><input type=\"button\" value=\"Terug\" onClick=\"javascript: history.go(-1)\"></form><br>";
exit;
}
$line = date("m-d-y") . " " . date("H:i") . " " . "|" . $HTTP_POST_VARS['name']; //* datum en tijd *//
$line .= "|" . $HTTP_POST_VARS['news'];
$line .= "|" . $HTTP_POST_VARS['image'];
$line = str_replace("
","<BR>",$line);
$line .= "
";
fwrite($fp, $line);
if(!fclose($fp)) {
echo "<font class=\"error_tekst\">Error! kan bestand niet afsluiten..</font><form><input type=\"button\" value=\"Terug\" onClick=\"javascript: history.go(-1)\"></form><br>";
exit;
}
} else {
echo "<font class=\"error_tekst\">Er is een niet correct paswoord in gevoert..</font><form><input type=\"button\" value=\"Terug\" onClick=\"javascript: history.go(-1)\"></form><br>";
exit;
}
}
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-2">
<meta http-equiv="creation-date" content="Decmber 2004">
<meta http-equiv="reply-to" content="info@huygmetaal.nl">
<meta name="robots" content="index, nofollow">
<meta name="e-mail" content="info@huygmetaal.nl">
<meta name="www" content="http://www.huygmetaal.nl">
<meta name="description" content="">
<meta name="keywords" content="">
<link rel="stylesheet" href="huyg_style.css" type="text/css">
<title>Huygmetaal, News system invoer pagina....</title>
<body bgcolor="#FFFFFF">
<font class="kop_tekst">Welkom bij Huymetaal Nieuws invoer systeem....
<br><br>
<font class="main_tekst"> Met dit systeem kunt u op de website van Huygmetaal nieuws toevoegen en/of verwijderen.. de datum wordt automatisch ingevoert..<br>
<FORM ACTION="<?=$PHP_SELF?>" METHOD="POST" NAME="newsentry">
<font class="main_tekst">Het Nieuws:<BR>
<TEXTAREA NAME="news" COLS="40" ROWS="5"></TEXTAREA><BR>
<font class="main_tekst">Uw paswoord:<BR>
<INPUT TYPE="password" SIZE="15" NAME="password"><BR>
<INPUT TYPE="submit" NAME="submit" VALUE="Verstuur"><BR>
</FORM>
<font class="kop_tekst">Laatste ingevoerde nieuws....</font><br><br>
<?
//*leest db in html en plaats *//
$data = file('news.txt');
$data = array_reverse($data);
//* insert KEY voor edit en delete functie *//
foreach($data as $element) {
$element = trim($element);
$pieces = explode("|", $element);
//* $pieces[?] 1=image 0=datum 2=nieuws *//
echo "<table width=\"40%\" border=\"0\"><tr>";
echo "<td><font class=\"main_tekst\">" . " Datum: " . $pieces[0] . "<br>" . " Nieuws: " . $pieces[2] . "<BR><hr align=\"left\" width=\"50%\" size=\"1\" color=\"#000000\"></td>";
echo "</font></tr></table>";
echo "<BR>
";
}
?>
</body>
</html>
maybe you can help me…