I have started studying PHP, and there is this one question that I don't seem to understand.
For eg. I have a PHP script at a URL: http://example.com/Test.php
If this script has a query that expects a parameter from the user (from a GET) then I could easily execute it like this:
http://example.com/Test.php?uid=2
where the query could be a
SELECT * FROM USERS WHERE UID = 2
Now I read that if I want to get sensitive information/upload to server I should use POST, but even if I use POST, I could still do the same in Postman with the parameters, and the query still executes.
I read about SQL injections and found that PDO is useful because it sends the query separately from the data to the server.
I have rewritten the first query with PDO, but I can still execute it with URL saying http://example.com/Test.php?uid=2. What am I doing wrong here? Am I misunderstanding something?
Questions:
- Is having public access to the scripts normal? Because it seems very unsecure to me.
- How is POST safer than GET when I can reproduce the same behavior in Postman?
- Why can I still run my code with PDO's with entering parameters in the URL? Isn't the point that we send them separately to the server, and there it gets executed?