okay, I am not an official newbie.. I know a little, but not alot.. what I'm trying to do is restrict people commenting on my band's news from using certain names. I'm using a PHP / MySQL news script I wrote from a tutorial final code here
it's active on my site here
I want to bypass the comments from being sent to the database and display "Invalid Name" when a user tries to post with a name I don't want them to use. Damnit, Jim.. I'm a musician, not a coder!
the comment form goes like this
echo "<FORM action=\"{$_SERVER['PHP_SELF']}" .
"?action=addcomment&id=$id\" method=POST>\n";
echo "Name: <input type=\"text\" " .
"width=\"30\" name=\"name\"><BR>\n";
echo "<TEXTAREA cols=\"40\" rows=\"5\" " .
"name=\"comment\"></TEXTAREA><BR>\n";
echo "<input type=\"submit\" name=\"submit\" " .
"value=\"Add Comment\"\n";
echo "</FORM>\n";
}
function addComment($id) {
global $db;
/* insert the comment */
$query = "INSERT INTO news_comments " .
"VALUES('',$id,'{$_POST['name']}'," .
"'{$_POST['comment']}')";
mysql_query($query);
//begin coment successful
include 'commentstuff.php';
srand ((double) microtime() * 1000000);
$randomquote = rand(0,count($quotes)-1);
echo "<p align=center>" . $quotes[$randomquote] . "</p>";
//end comment successful
echo "<a href=\"{$_SERVER['PHP_SELF']}" .
"?action=show&id=$id\">Back</a>\n";
echo "</TABLE>\n";
}
I've tried using IF statements, buuuut, I'm an idiot and eff up the syntax.. any help would be mucho appreciated.. thanks!