@robertbralic007 you posted that the INSERT does not work.
Without knowing what error messages, if any. you were getting, we know two things.
- there might be a problem with the PHP code
- there might be a problem with the query
I can not speak for others, but I can say what I do when I am faced with this.
* note that while working up code during development I always have as much error reporting as possible.
To be fair, yes, writing your code in a syntax that helps you to avoid and spot errors is a very good idea. And yes, security should be integral not an afterthought.
Currently I have gotten into the habit of testing queries outside of PHP before I write any PHP code for them. I prefer the CLI (Command Line Interface) but I think phpMyAdmin is good to use too if you’re more comfortable with that.
Only after I am as certain as I can be that the query works as I want it to do I then start writing the PHP.
Some prefer mysqli_, some PDO. Some prefer procedural syntax, others OOP syntax. Sadly many seem to still be writing obsolete mysql_ that is a FAIL waiting to happen sooner rather than later. It is also sadly true that many write insecure code and are satisfied with “it works”.
Anyway, here’s what I suggest.
- if you don’t have error reporting and error display set up, do so. It will let you know of syntax errors and other problems as well as make trouble shooting easier during development.
- if you get an error pointing to a database problem instead of a PHP problem, test the query outside of any PHP code.