Hacker News new | ask | show | jobs
by guidedlight 778 days ago
I agree. However those ‘crazy things’ you can do with PHP very easily cause security defects.

Mixing server side and front end code is bad news. I think following many PHP-MySql tutorials will result in SQL injection vulnerabilities. Not good.

1 comments

i have nightmares from PHP, too, so i get where you're coming from. but i think you'd have to go back at least a decade to find tutorials that bad
Not an SQL injection, but I opened Google in a private browsing window, searched for “php mysql tutorial”, and it brought me to the W3Schools tutorial, which has multiple other vulnerabilities relating to how PHP just dumps its output into HTML unescaped without a second thought. At a glance, I see obvious XSS and open redirect vulnerabilities.

https://www.w3schools.com/php/php_mysql_select.asp

W3Schools being consistently shit for decades doesn't really reflect badly on PHP specifically.
It’s the top hit for “PHP MySQL tutorial”. This is what PHP newbies are learning from.

The same tutorial with Django wouldn’t have the same problem because Django auto-escapes strings you dump into HTML. These vulnerabilities only exist in this tutorial because PHP treats its output as HTML by default not text, so you need to put in extra effort to be secure.

Django is a framework. If you want to compare against it you'd look at Laravel tutorials.
It’s how people write code for the web with Python. Substitute Flask if you like.

People who are new to PHP and want to learn how to use MySQL will search for “PHP MySQL tutorial” and they will find insecure garbage.

The fact that you can find good tutorials does not negate the fact that people do find terrible ones.