I have a dead simple news/comment posting thing, and I want to add basic password authentication to it. I don't care if it's plaintext, in a database, or even embedded into the script as it is now! I just want people to type in their username, type in their password, type in their comment, hit "post," and go! I'll include the script below. Any thoughts?
<head>
<title>yourpage</title>
</head>
<body>
yadda yadda yadda
<P>
what's below is all posts, baby:
<hr noshade>
<?php
if ($message)
{
$message = stripslashes($message);
$message = ereg_replace("\r\n\r\n", "\n<P>", $message);
$date = date("m.j.y :: h.i.a");
$message = "<B>$name</B> posts at $date<br />$message<P>\n";
$lines[] = $message;
$filename = 'index.php.comment';
$in = fopen( $filename, 'r' );
while( !feof( $in )) {
$lines[] = fgets( $in, 1024 );
}
fclose( $in );
$out = fopen( $filename, "w" );
foreach( $lines as $line ) {
fputs( $out, $line );
}
fclose( $out );
}
readfile("index.php.comment");
?>
<hr noshade>
<font size="1">
<FORM method="post">
<b>name/e-mail:</b><BR><INPUT name="name" type="text" size="50"><BR>
<b>thoughts:</b><BR><TEXTAREA name="message" rows=10 cols=75 wrap=virtual>
</TEXTAREA>
<BR>
<INPUT name="submit" type="submit" value="post">
</FORM>
</font>
</body>