airportmarc Posted June 27, 2008 Share Posted June 27, 2008 Hey there all, So I am trying to validate users inputs from forms using PHP. I have a few different functions that check the email,dates,text,etc.. But I get loss when trying to implement them on a bunch of different forms. there are about 10-15 different forms that need to be checked (all on different pages) and i am trying to find the most efficient way of doing this. My current idea is to create a different function for each form that checks the correct fields for that form. So if form1 has 2 text fields, 1 date field, 1 email, a function call form1 is called and within that it checks 2 texts, 1 date and 1 email... Is this good programming style? Also, I am looking for a better way to report any errors to the user. Currently the functions return a string saying something like "thank you" or "Sorry that was incorrect". I am looking for a way to build an array or error(s) as they come up and display that to the user. I hope this is clear, please ask if you need further clarification. Link to comment https://forums.phpfreaks.com/topic/112238-form-vailadation/ Share on other sites More sharing options...
Jabop Posted June 27, 2008 Share Posted June 27, 2008 I say just validate each field individually. That's just my opinion, though. Link to comment https://forums.phpfreaks.com/topic/112238-form-vailadation/#findComment-576241 Share on other sites More sharing options...
dazzclub Posted June 27, 2008 Share Posted June 27, 2008 when im building a form i try to make the error string as descriptive/helpful as they can be. Link to comment https://forums.phpfreaks.com/topic/112238-form-vailadation/#findComment-576247 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.