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 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化