dtch60248 2019-05-01 15:07
浏览 13

如何在没有绑定参数的情况下检查MySQL Injection的变量[重复]

This question already has an answer here:

:)

I'm working on a server list website, but I have a problem about security with a searching bar. I would like to allow users to search servers from my website, so I did a searching bar. But when they are searching, servers are display by a system of pagination which works with affix. Some values affects a MySQL command to execute pagination. So I can't use prepare then bind_param because some param contains WHERE etc. But
To be more comprehensive, i show you the code:

    if (isset($_GET['searchserver'])){
        $searchserver = $_GET['searchserver'];
        $truevalue = '%' . $searchserver . '%';
        $this->where = "WHERE `name` LIKE '{$truevalue}' ";
    }

So, it is working, but I want to check the variable $searchserver before adding it into my $this->where. I would like to know if i can check it, and if it does not contains something different than a server name. (A server name may have numbers and letters but not strange characters like ; : , .) Is it possible ? I can't use bind param..

Thank you for your time and sorry for my bad english !

</div>
  • 写回答

1条回答 默认 最新

  • duankuaiwang2706 2019-05-01 15:16
    关注

    Even though it doesn't make sense why you don't use pdo ,

    you can add a bunch of sanity filtering to the input

    https://www.php.net/manual/en/book.filter.php

    评论

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答