dougang1965 2012-05-21 02:44
浏览 95
已采纳

Php preg_match问题

With following php preg_match i'm trying to show a error message if someone input any value except a-z or 0-9 in a textarea form. Just only user can type string and numerice value. Not , < ? >any php, javascript tag etc.

if(preg_match("/^[a-zA-Z0-9]+/ ", $wall) != 1)
$err[] = "Wrong value";

So, if i put php tag to the begning of the form then it's show error message but if i put "Some text then type php tag and another value" then it's doesn't show any error message.

Sorry my bad english.:(

  • 写回答

3条回答 默认 最新

  • duannian3494 2012-05-21 02:56
    关注

    You could just check whether there is any character you don't want.

    if(preg_match("/[^a-zA-Z0-9]/ ", $wall)) {
      $err[] = "Wrong value";
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 关于#网络安全#的问题:求ensp的网络安全,不要步骤要完成版文件
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥20 使用Photon PUN2解决游戏得分同步的问题
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM