|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
PHP form verification?
Hello,
I have created a guestbook in PHP from scratch since the CGI version included with my web hosting package sucks. Everything works great, except that lately, people have been pressing the submit button without entering text in the text fields, thus emailing me a link to the page and there lies a blank entry. I'm getting tired of deleting the blanks and it dawned on me that there might be a way to require at least one field to have text or it won't popluate the database, but I don't have a clue how to do it. I have all of the fields NULL (except for the entry_ID), but I don't want the user to have to fill out every field either. Can anyone tell me how to verify that at least one field has text or no submission? Any help would be greatly appreciated! Thanks! Ryan |
|
#2
|
|||
|
|||
|
Ryan,
Lets us assume the field you wish to verify has a name of 'message'. In your PHP code you want to do the following: PHP Code:
In english, the above code says, If message is in the POST headers, add it to the $message variable, but if it is in the GET message do the same. If both were available, GET would override POST. If neither exist or is blank code execution stops.
__________________
__________________________________________________ _ Wil Moore III, MCP | Integrations Specialist | Senior Consultant Are You Listed...? | DigitallySmooth Inc. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > PHP form verification? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|