Mysqli prepared statement (SQL injection prevention)

前端 未结 2 609
野趣味
野趣味 2021-01-06 11:49

after stopping the use of deprecated mysql_* functions, I switched to mysqli. But then, I noticed that non-prepared statements are non-secure against SQL injection. Then, I

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-06 12:26

    Your mysqli logic seems fine, there are some examples in the PHP manual here in case you have not seen them.

    Why are you selecting the ID when not consuming it though? Also you don't really need to bind a result when it's only going to have one row returned in the full result set as I assume will happen in this case (ID is unique index in the table), use get_result instead.

    Using mysqli prepare will protect against all the common injection attacks but not 0-day style stuff which hasn't made it to the driver yet.

提交回复
热议问题