PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have a working form with javascript validation (checks to see if somthing is entered in fields before it is submitted).
But if people go to the processor page it will submit the form with nothing on it. Like it will just submit a blank form. Any way to prevent the form from entering if a value equals nothing.
i just dont want people going to the form processor page because it floods my email, i want to make a block on it, so there has to be somthing being sent for it to send? get what i mean?
<?
header('Location:/pages/report.php');
include("/home/muot/dbc.php");
mysql_query("update votes set number_of_votes = number_of_votes + 1 where answer = '$vote'");
$page = "thank you - voting.";
include('/home/muot/add2stat.php');
$content = "
<tr><td><b>$name</b> voted this muot as a $vote !<br>
<b>$name said $comments</td></tr>
";
$filename = '/home/muot/public_html/pages/report.php';
if (is_writable($filename)) {
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
if (fwrite($handle, $content) === FALSE) {
echo "Cannot write to file ($somecontent)";
exit;
}
echo "";
fclose($handle);
} else {
echo "The file $filename is not writable";
}
?>
That works, just how I want it.
But if someone goes to http://www.mysite.com/process.php , it will write blank data to a page. I want to stop the script from doing anything if there is not any data inputed.
I tried to add your script but I got a parse error, unexpected } on line 4 , line 4 is }.
Sounds like you have a syntax error. Check your { and your } and make sure they're all closed.
What you want to do is check to find out if you have a submission to the page. If there is process the page. If there isn't, don't process it. That's the concept.
To add to my last post, I got it working. I added what Jcart told me to do, and it worked. The parse error was coming from the die("blah") , Jcart forgot to add a ; at the end. Its all good.
nickman013 wrote:To add to my last post, I got it working. I added what Jcart told me to do, and it worked. The parse error was coming from the die("blah") , Jcart forgot to add a ; at the end. Its all good.
Thanks For the Help Guys!
fyi I just copy and pasted your snipplet (and edited slightly)..