3 ms·
Could u explain why HTML&PHP&SQL is bad? And is it only bad when all three are combined?
by maruhan2 11y ago
Could u explain why HTML&PHP&SQL is bad? And is it only bad when all three are combined?
- tehbeard 11y agoseparation of concerns and DRY would be the two main reasons I'd put forward. Anything involving manipulating your data / business logic should not be embedded in a template. PHP in your html should really be for display/rendering (i.e. looping over a list of Employee records), it should not be fetching those records itself (either by Employee::fetchAll() or especially mysql_query("SELECT * from employee") )
- jwdunne 11y agoI don't think you should have been down voted for this question. It discourages asking to learn. What I meant was mixing them together in the same piece of code. The other comments explain why: its doing too much, its difficult to maintain and reason about so its harder to find bugs, especially serious ones, and difficult to fix them.
- foxhop 11y agoResearch "model view controller" and separation of concerns. It is very hard to maintain or even reason about a file or make a change or secure exploitable edge cases when the application has html, css, javascript, php, and calls to the database in the same place.