PDA

View Full Version : PHP Filter on a Form



dshaw
05-07-2008, 01:50 PM
I'm a very novice user with html and php. Website and php form is in place working correctly before i got here. We receive many blank forms or forms with only one field filled out from users that must sit there and click submit. Is there a way to force a pop up when not enough has been filled out. Or if easier block the form from being sent. Thanks in advance. P.S. A filter.txt file is already set up that has a list of bad words in it.

Cronos
05-07-2008, 07:16 PM
I guess this falls under the category 'form validation'.

Just google that term. (for example this (http://www.php-mysql-tutorial.com/form-validation-with-php.php))

djr33
05-07-2008, 09:40 PM
PHP happens AFTER it is submitted. Javascript can occur while they are typing on the form.

Some Javascript form validation scripts are available, so look around. Required fields, etc., fall into that.

but then of course you'll want a backup PHP script like what was linked above.

TimFA
05-07-2008, 09:42 PM
Just curious, is there a specific reason no one has provided him with a simple JavaScript example of this? I was considering it, but then decided to ask if I missed something lol.

djr33
05-07-2008, 10:08 PM
Certainly feel free to post. The original post is vague, asking for a popup and for PHP, so I said he can find something by looking through the DD library (and posts/submissions) if desired.

TimFA
05-07-2008, 10:29 PM
Alright, I will post something in a bit to show off how it could be done with JavaScript, I just wasn't sure if maybe there was something I missed, like maybe he didn't want an actual code. Thanks.

matthewbluewars
05-11-2008, 07:40 PM
If you want to make a popup or related message BEFORE it's submitted, then you shold use a client-side language (most likely JavaScript) for you validation. Otherwise the server will have to deal with processing blank data, and you can't display anything on the same page (usually) or a client-side message (ie pop).