Simple PHP problem i think
Posted: Sun Dec 20, 2009 3:33 pm
Hello, i would love some help with this problem, What i have is a simple page with a comments textarea box, when submit is clicked it sends the comment to a seperate php file i have shown below, then it refreshes back to the comment box page and displays the comment in real time and emails me, But i noticed i get slammed to death with drug links and such, So then i added a JAVA submit button and JAVA word filter in the hopes that if they turned off there java, the submit button wont function, but low and behold they must be using a keyboard event to trigger the submit action anyway, so is there anyway to wire in a simple php script on top of the script i have included below, a php word filter that will not pass the data to the "comments open and insert comment to the flatfile" if say the word vi---gra or http or www is found, and perhaps give an alert or just redirect back to the comment input page without listing the comment, im thinking getting the php word trap here were the comment comes in for listing, would be best, as no Onclick or Onkeyup will work with java turned off, any help would be greatly appreciated, here is my php comments insert to flatfile code, that i want to add a php word trap on top of.
php code
<?
/* this part can either be in the same file as the form or it can be in a different file. If you want this in a different file, make the "action" of the form go to that file */
$fc = fopen("comments.txt","a+b"); //opens the file to append new comment -
fputs($fc,$_POST['comments']."\n\n\nNewComment->"); //writes the comments followed by a
fclose($fc); //closes the files
if(sizeof($_POST)) {
$body = "";
while(list($key, $val) = each($HTTP_POST_VARS)) {
$body .= "$key: $val \n";
}
mail("myEmail@myEmail.com", // to
"Subject Line",
$body);
header("Location: myproject.html");
}
php code
<?
/* this part can either be in the same file as the form or it can be in a different file. If you want this in a different file, make the "action" of the form go to that file */
$fc = fopen("comments.txt","a+b"); //opens the file to append new comment -
fputs($fc,$_POST['comments']."\n\n\nNewComment->"); //writes the comments followed by a
fclose($fc); //closes the files
if(sizeof($_POST)) {
$body = "";
while(list($key, $val) = each($HTTP_POST_VARS)) {
$body .= "$key: $val \n";
}
mail("myEmail@myEmail.com", // to
"Subject Line",
$body);
header("Location: myproject.html");
}