Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Same name for form fields & database table fields?

Is it considered bad practice to give HTML form names the same name as table field names? I am building some dynamic sql insert queries, and at present I am using some regexp's to change the names to the relevant database fields on the basis I feel it may be insecure otherwise, what are your opinions?

like image 339
Jimmy Avatar asked Oct 08 '22 02:10

Jimmy


1 Answers

I wrote a function to do INSERT queries for me, and it depends on that fact. It takes the $_POST variable names and INSERTs them into their corresponding columns.

As said in the comment on the OP, it doesn't matter, and in most cases, saves you time going back to remember if you used first_name, firstname, or first.

Also, keep in mind that your users will never see the database column names, and they will only see the form names if they view the source. Therefore, there's not much to worry about!

Good luck!

like image 110
David Avatar answered Oct 13 '22 11:10

David