3 ms·
Non-PHP, non-Laravel person here just trying to learn. That looks pretty good to me. What bad practices does it encourage?
by tomcam 5y ago
Non-PHP, non-Laravel person here just trying to learn. That looks pretty good to me. What bad practices does it encourage?
- XCSme 5y agoI wrote that example, which is simplified, but here are some security things to keep in mind when dealing with PHP/MySQL: - Always use PDO prepared statements to avoid SQL injections - Should probably implement a CSRF token check - You shouldn't output values directly from the user/database and that can lead to XSS attacks (either sanitize the stored data, or when outputting it make sure the page is always interpreted as plain text) - You might forget to check for permissions in a specific route (code enforce this via some linting/IDE rules, by using some automated tests or by checking in an included shared script that permissions were indeed verified)
- ipaddr 5y agoAlways use PDO prepared statements to avoid SQL injections? Sanitize your data and use whatever driver you want. Prepare statements are like sending xml instead of json. If you are populating a database with known data why add the overhead?
- tomcam 5y agoThank you. Somehow, I thought the tree structure they described for breaking down program logic was the problem. Obviously I agree with all the other stuff, which is table stakes for a safe web app