/    Sign up×
Community /Pin to ProfileBookmark

form security and validation – Classes???

? Hello all,

I am looking for a little input here on form security and validation.

I am working on my first PHP/MySQL site with a LOT of forms of one type or another and as about 90% of them feed back to the database. So I have two questions I hope you can help me out on…

can I use a class (I’ve never used one before) to do most of the work? i.e.
strip_tags()
strip_slashes()
allow only [A-Z], [a-z], [0-9]
[- _ @ : ; , .]
and anything else you can think of to make forms more secure???

Secondly can I do something similar, maybe including javascript to validate required fields?

Many thanks

Mouse

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYMar 16.2006 — You would probably want to have a database interaction class, which you could then extend to a form processing class in which you would add the validation methods

you would then call it with something like

[code=php]
$validate = $form_processing->validate($_POST['field'], $type);[/code]
Copy linkTweet thisAlerts:
@Mouse77eauthorMar 16.2006 — You would probably want to have a database interaction class, which you could then extend to a form processing class in which you would add the validation methods

you would then call it with something like

[code=php]
$validate = $form_processing->validate($_POST['field'], $type);[/code]
[/QUOTE]


Sorry i should have mentioned... i am new to classes... in fact as i write this i am looking for tutorials on the subject... but thanks for the input all the same ?

Mouse
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYMar 16.2006 — Read the "language reference" part in the manual (classes and objects php4/5)
Copy linkTweet thisAlerts:
@NogDogMar 16.2006 — If you've not worked with object-oriented programming before, the PHP manual won't really explain why and when to use classes and objects, just the syntax. You might therefore want to start by learning some of the basics of O-O. Here's one general tutorial I found: http://java.sun.com/docs/books/tutorial/java/concepts/index.html
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYMar 16.2006 — Zend.com has a couple of interesting articles and tutorials about OOP

edit: i think..
Copy linkTweet thisAlerts:
@schizoMar 16.2006 — Once you have basic OOP knowlege, take a look at http://www.phpbuilder.com/columns/weiner20050831.php3

It's an article that I wrote last year on Object-Oriented form validation.
×

Success!

Help @Mouse77e spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...