Quote:
Originally Posted by InfamousNoone
edit: u guys r probably like whoa wtf infamous was nice who is this guy
|
No one ever said that. <3
OP: If you start thinking about structure and usability, PHP will be a lot more smoother for you.
When it comes to your DB connection, but as I'm sure you're well aware of at this point; don't use mysql_*, it's deprecated and it's literally one more letter (mysqli) and you're running mysqli. Use this with prepared queries and normal sanitizing of inputs and you're set.
Don't define your connection on top of the file. Instead, pass along a global variable (the connection) wherever it's needed. Globals are highly controversial, so read up on it and decide for yourself.
And yeah.. Split front and backend. Don't echo out html. Don't run php-queries inside a huge html block. Best case scenario would be MVC - where you have a templates folder with just the different parts of front end, views folder with db-connection to load data and controller to save (register etc)