I have a simple php text file that just captures input and I'd like to beef it up a little so I don't get 5,000 blank msgs when someone keeps hitting the 'submit' button. I have some generic code for limiting text and forcing the user to enter info before sending, but I think thats more for a mailto: php form.
<HTML>
<HEAD>
<TITLE> Register </TITLE>
</HEAD>
<BODY>
<?php
$out = fopen("register.txt", "a");
if (!$out) {
print("server is down, please try later");
exit;
}
fputs($out,"$_POST[name]\n");
print("Thank You!");
fclose($out);
?>
</BODY>
</HTML>
Generic code for 'character force'(which I stole from a tutorial) are:
if(strlen($name) == 0)
{
echo "It would appear that you have not put your Name in the Name Field. Please use the Back Button to return to the form and put your Name in that field. Thank you!";
exit;
}
They're all "IF" strings for character limits, and such to help protect against injection, but my initial args were for:
$name = $HTTP_POST_VARS['name'];
I know it's kind of confusing, but the first code I posted works great for simple name capture and I can always expand it for other fields(I just wanted to get it working). But it's only a txt file capture, which I don't care about since i'm always signed on working on the website anyways. I think I'm confusing the mailto: args because I can't seem to incorporate 'if' args in my statements.
Anybody have a workthrough for this? or am I jsut gonna have to dump my txt file all the time for blank submits?
MC