doudou2121 2013-04-03 03:26 采纳率: 50%
浏览 85
已采纳

来自jQuery ajax帖子的PHP表单验证

I have a form (firstname, lastname etc) which is validated client side using http://bassistance.de/jquery-plugins/jquery-plugin-validation/ validator. I am then posting the form fields to the server using ajax serialize() however I was wondering if someone could share a class (or link to class) for the server side validation.

I have tried using http://www.html-form-guide.com/php-form/php-form-validation.html but this looks like this class is expecting the name of the form field to apply validation.

Thanks

  • 写回答

2条回答 默认 最新

  • dongsi4547 2013-04-03 03:53
    关注

    ...ok, if you are looking for sanitizing the passed value to make sure no bad things get through than you can look here: http://php.net/manual/en/filter.filters.sanitize.php

    if you are looking for 'validation' based on some pre-set rules, please specify.

    You can also partially sterilize the passed values like this if you do need only basic char. set:

    function sterilize($input) {
    
    $input = htmlentities($input);
    
    $input = strip_tags($input);
    
        return $input;
    
    }
    

    FYI as you mentioned below, for the email address you could youse something like this:

    $email = isset($_POST['email']) ? filter_var($_POST['email'], FILTER_SANITIZE_EMAIL): '';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码