In PHP, how does PDO protect from SQL injections? How do prepared statements work?

后端 未结 4 477
你的背包
你的背包 2020-12-15 08:45

I understand the right way to protect a db from SQL injection is by using prepared statements. I would like to understand how prepared statements protect m

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-15 09:08

    your source is secure from sqli attack.

    it's example and not secure when you select one the user from your database.

    // example: localhost/user.php?username=admin
    
    $getdata = $_GET['username'];
    
    $dbConnection=$this->dbInstance->createConnexion();
    $query=$dbConnection->prepare("SELECT * FROM users WHERE username=".$getdata.");
    
    // PHP simple
    

提交回复
热议问题