PHP - How to Create Dynamic URLs?

前端 未结 5 663
挽巷
挽巷 2021-02-06 17:32

I\'ve scoured the web for a tutorial about this simple task, but to no avail. And so I turn to you helpful comrades. Here\'s what I need to do:

I have a MySQL database w

5条回答
  •  北荒
    北荒 (楼主)
    2021-02-06 17:49

    It's wise to take extra care when you are using $_GETvariables, because them can be easily altered by a malicious user.

    Following with the example, you could do:

     $foo = (int)$_GET['id'];
    

    So we are forcing here the cast of the variable to a integer so we are sure about the nature of the data, this is commonly used to avoid SQL injections.

提交回复
热议问题