<?php
elseif ($somethinggoeshere??? == "login") {
include ("config.php");
if (snewz_auth($username, $password, &$error)) {
echo "Welcome to SNEWZ!";
} else {
echo"Wrong Username or Password.";
}
elseif ($somethinggoeshere??? == "postnewz") {
include ("config.php");
if($your_name=="$username" &&
$your_password=="$password"){
$your_date = date("M j, Y ");
$fp=fopen("./comments.dat", "a");
fputs($fp, "<tr><td>Posted by <a href=mailto:$your_email target=_blank>$your_name</a> at $your_date</td></tr><tr><tr><td> <a href=$your_url>$your_subject</a></td></tr><tr><td>$your_comments</td></tr>");
$news = str_replace(" ", "", $fcontents[$i]);
fclose($fp);
include "comments.php";
}
else{
echo"Incorrect username or password.<br>";
}
$fp1 = fopen("./comments.dat", "r");
$readit = fread($fp1, filesize("./comments.dat"));
fclose($fp1);
$newspiece = $readit . $news;
$fp = fopen("./comments.dat", "w+");
fwrite($fp, $newspiece);
fclose($fp);
elseif ($somethinggoeshere?? == "viewnews") {
echo "<table cellspacing=0 cellpadding=3 border=0>";
$fcontents = file('comments.dat');
$c = count($fcontents);
$limit = 5;
for ($i = 0; $i < $limit; $i++){
$news = $fcontents[$i];
if($news != ""){;
echo "$news \n";
}
}
echo "</table>";
?>
I was wondering if anyone woul dlike to clean up my code a bit.
I am learning php I am not sure about the limiting for the view news or the postnewz script.
Also I think I have the script wrong in which you post new news to the top an dold to the bottom but I am not sure.
thanks
cya
Sam Colebatch
sam@samcolebatch.com
http://www.samcolebatch.com