Escaping variables

后端 未结 4 1901
轻奢々
轻奢々 2020-12-10 21:11

I\'ve read that it\'s enough and even recommended to escape characters on the output, not on the input.

It could be easily applied to all get variables as they are n

4条回答
  •  感动是毒
    2020-12-10 21:55

    I use mysqli_real_escape_string and preg_replace

    $email = mysqli_real_escape_string($dbc, trim($_POST['email']));
    $password = mysqli_real_escape_string($dbc, trim($_POST['password']));
    $domain = preg_replace('/^[a-zA-Z0-9][a-zA-Z0-9\._\-&!?=#]*@/', '', $email);
    

    Also, here is a link to a similar post regarding PDO escaping Escape arguments for PDO statements?

提交回复
热议问题