//这个函数主要用来检查提交的表单数据是否有错(validate)
//实际应用上用户输入数据的检验(validate)及过滤(filter)都涉到程序安全性,非常重要,必不可少
//在写实际应用时不会把$_POST直接放在函数里,这里是一个姑息的解决方法,希望大家能改正
if( $_POST )
{
form_error();
}
function form_error() {
$_POST['name'] = trim(strip_tags($_POST['name'])); //这个实际上是Filter
$len_name = strlen($_POST['name']);
if($len_name > 30 || $len_name
$msg = '姓名长度必须大于2小于30
';
}
$date = explode('-', $_POST['birthday']);
if(sizeof($date) != 3) {
$msg .= '日期格式错误
';
} else {
if(!checkdate($date[1], $date[2], $date[0])) {
$msg .= '日期不正确
';
}
}
if(!eregi("^[a-z'0-9]+([._-][a-z'0-9]+)*@([a-z0-9]+([._-][a-z0-9]+))+$", $_POST['email'])) {
$msg .= '邮箱格式错误';
}
return $msg;
}
?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6
Visual web development tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Dreamweaver Mac version
Visual web development tools