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条)

报告相同问题?

悬赏问题

  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿