Forum Moderators: open
can you verify form field values before sending them to a database?
I dont want to verify IF a value is there, or IF the value is of proper format...
I want to, for instance, see if a record already exists...
In my form, if you enter John for the first name, and Smith for the last name, when you hit "submit" it will query the dbase for that combination of values, and alert if it already exists...
If it does you can cancel, of it doesnt, it will submit.
Performing a query before each attempt to insert seems inefficient to me as you are performing a SELECT + an INSERT for users that don't already exist. With the approach above you only attempt 1 SQL statement per attempted transaction.
can you verify form field values before sending them to a database?
Of course you can. You will have to modify whatever script is accepting the data, of course.
My favorite refrain from working on a 15-person multi-million dollar software project, when asked by the CEO "can you do...."
"We can DO anything!"
("It's just a matter of cost and effort.")
IF you are using a database that supports triggers, AND your existing scripts handle errors in an intelligent manner, you MIGHT get away with simply adding triggers to the database validate the data.
But probably not.