本文整理汇总了PHP中Validate::checkNull方法的典型用法代码示例。如果您正苦于以下问题:PHP Validate::checkNull方法的具体用法?PHP Validate::checkNull怎么用?PHP Validate::checkNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validate
的用法示例。
在下文中一共展示了Validate::checkNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
private function add()
{
if (isset($_POST['send'])) {
if (Validate::checkNull($_POST['admin_user'])) {
Tool::alertBack('警告:用户名不得为空!');
}
if (Validate::checkLength($_POST['admin_user'], 2, 'min')) {
Tool::alertBack('警告:用户名不得小于两位!');
}
if (Validate::checkLength($_POST['admin_user'], 20, 'max')) {
Tool::alertBack('警告:用户名不得大于20位!');
}
if (Validate::checkNull($_POST['admin_pass'])) {
Tool::alertBack('警告:密码不得为空!');
}
if (Validate::checkLength($_POST['admin_pass'], 6, 'min')) {
Tool::alertBack('警告:密码不得小于六位!');
}
if (Validate::checkEquals($_POST['admin_pass'], $_POST['admin_notpass'])) {
Tool::alertBack('警告:密码和密码确认必须一致!');
}
$this->_model->admin_user = $_POST['admin_user'];
if ($this->_model->getOneManage()) {
Tool::alertBack('警告:此用户已被占用!');
}
$this->_model->admin_pass = sha1($_POST['admin_pass']);
$this->_model->level = $_POST['level'];
$this->_model->addManage() ? Tool::alertLocation('恭喜你,新增管理员成功!', 'manage.php?action=show') : Tool::alertBack('很遗憾,新增管理员失败!');
}
$this->_tpl->assign('add', true);
$this->_tpl->assign('title', '新增管理员');
$this->_tpl->assign('prev_url', PREV_URL);
$_level = new LevelModel();
$this->_tpl->assign('AllLevel', $_level->getAllLevel());
}
示例2: add
private function add()
{
if (isset($_POST['send'])) {
if (Validate::checkNull($_POST['admin_user'])) {
Tool::alertBack('username empty');
}
if (Validate::checkLength($_POST['admin_user'], 2, 'min')) {
Tool::alertBack('username less than 2');
}
if (Validate::checkLength($_POST['admin_user'], 20, 'max')) {
Tool::alertBack('username more than 20');
}
if (Validate::checkNull($_POST['admin_pass'])) {
Tool::alertBack('password empty');
}
if (Validate::checkLength($_POST['admin_pass'], 6, 'min')) {
Tool::alertBack('password less than 6');
}
if (Validate::checkEquals($_POST['admin_pass'], $_POST['admin_notpass'])) {
Tool::alertBack('password not match');
}
$this->_model->admin_user = $_POST['admin_user'];
if ($this->_model->getOneManage()) {
Tool::alertBack('this username registered already');
}
$this->_model->admin_pass = md5($_POST['admin_pass']);
$this->_model->level = $_POST['level'];
$this->_model->addManage() ? Tool::alertLocation('Succeed', 'manage.php?action=show') : Tool::alertBack('Fail');
}
$this->_tpl->assign('add', true);
$this->_tpl->assign('title', 'Add New Administrator');
$this->_tpl->assign('prev_url', PREV_URL);
$_level = new LevelModel();
$this->_tpl->assign('AllLevel', $_level->getAllLevel());
}
示例3: check_data
private function check_data()
{
import("@.Tool.Validate");
//验证类
//数据验证
if (Validate::checkNull($_POST['name']) || Validate::checkNull($_POST['content'])) {
$this->error('请输入对应内容');
}
}
示例4: index
public function index()
{
if (!empty($this->oUser)) {
$this->redirect('/User/user_list');
}
if ($this->isPost()) {
$Users = D('Users');
//用户表模型
import("@.Tool.Validate");
//验证类
$account = $_POST['account'];
//用户账号
$password = $_POST['password'];
//用户密码
//数据过滤
if (Validate::checkNull($account)) {
$this->error('账号不得为空');
}
if (Validate::checkNull($password)) {
$this->error('密码不得为空');
}
if (!Validate::check_string_num($account)) {
$this->error('账号密码只能输入英文或数字');
}
//读取用户数据
$user_info = $Users->get_user_info(array('account' => $account, 'type' => 0, 'status' => 0));
//验证用户数据
if (empty($user_info)) {
$this->error('此用户不存在!');
} else {
if (md5($password) != $user_info['password']) {
$this->error('密码错误!');
} else {
$tme_arr = array('id' => $user_info['id'], 'account' => $user_info['account'], 'name' => $user_info['name']);
$_SESSION['user_info'] = (object) $tme_arr;
//保存用户信息
//更新用户信息
$Users->up_login_info($user_info['id']);
$this->redirect('/System/index');
}
}
}
$this->display();
}
示例5: login
private function login()
{
if (isset($_POST['send'])) {
if (Validate::checkLength($_POST['code'], 4, 'equals')) {
Tool::alertBack('警告:验证码必须是四位!');
}
if (Validate::checkEquals(strtolower($_POST['code']), $_SESSION['code'])) {
Tool::alertBack('警告:验证码不正确!');
}
if (Validate::checkNull($_POST['admin_user'])) {
Tool::alertBack('警告:用户名不得为空!');
}
if (Validate::checkLength($_POST['admin_user'], 2, 'min')) {
Tool::alertBack('警告:用户名不得小于两位!');
}
if (Validate::checkLength($_POST['admin_user'], 20, 'max')) {
Tool::alertBack('警告:用户名不得大于20位!');
}
if (Validate::checkNull($_POST['admin_pass'])) {
Tool::alertBack('警告:密码不得为空!');
}
if (Validate::checkLength($_POST['admin_pass'], 6, 'min')) {
Tool::alertBack('警告:密码不得小于六位!');
}
$this->_model->admin_user = $_POST['admin_user'];
$this->_model->admin_pass = sha1($_POST['admin_pass']);
$this->_model->last_ip = $_SERVER["REMOTE_ADDR"];
$_login = $this->_model->getLoginManage();
if ($_login) {
$_preArr = explode(',', $_login->premission);
if (in_array('1', $_preArr)) {
$_SESSION['admin']['admin_user'] = $_login->admin_user;
$_SESSION['admin']['level_name'] = $_login->level_name;
$_SESSION['admin']['premission'] = $_preArr;
$this->_model->setLoginCount();
Tool::alertLocation(null, 'admin.php');
} else {
Tool::alertBack('警告:权限不够,您无法登录!');
}
} else {
Tool::alertBack('警告:用户名或密码错误!');
}
}
}
示例6: reg
private function reg()
{
if (isset($_POST['send'])) {
parent::__construct($this->_tpl, new UserModel());
if (Validate::checkNull($_POST['user'])) {
Tool::alertBack('empty username');
}
if (Validate::checkLength($_POST['user'], 2, 'min')) {
Tool::alertBack('username less than 2');
}
if (Validate::checkLength($_POST['user'], 20, 'max')) {
Tool::alertBack('username more than 20');
}
if (Validate::checkLength($_POST['pass'], 6, 'min')) {
Tool::alertBack('password less than 6');
}
$this->_model->user = $_POST['user'];
$this->_model->pass = md5($_POST['pass']);
$this->_model->email = $_POST['email'];
$this->_model->face = $_POST['face'];
$this->_model->state = 1;
$this->_model->time = time();
$this->_model->question = $_POST['question'];
$this->_model->answer = $_POST['answer'];
if ($this->_model->checkUser()) {
Tool::alertBack('duplicate username');
}
if ($this->_model->checkEmail()) {
Tool::alertBack('duplicate email address');
}
if ($this->_model->addUser()) {
$_cookie = new Cookie('user', $this->_model->user, 0);
$_cookie->setCookie();
$_cookie = new Cookie('face', $this->_model->face, 0);
$_cookie->setCookie();
Tool::alertLocation('succeed', './');
} else {
Tool::alertBack('fail');
}
}
$this->_tpl->assign('reg', true);
$this->_tpl->assign('OptionFaceOne', range(1, 9));
$this->_tpl->assign('OptionFaceTwo', range(10, 24));
}
示例7: addComment
private function addComment()
{
if (isset($_POST['send'])) {
$_url = 'http://' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
if ($_url == PREV_URL) {
if (Validate::checkNull($_POST['content'])) {
Tool::alertBack('警告:评论内容不得为空!');
}
if (Validate::checkLength($_POST['content'], 255, 'max')) {
Tool::alertBack('警告:评论内容长度不得大于255位!');
}
if (Validate::checkLength($_POST['code'], 4, 'equals')) {
Tool::alertBack('警告:验证码必须是四位!');
}
if (Validate::checkEquals(strtolower($_POST['code']), $_SESSION['code'])) {
Tool::alertBack('警告:验证码不正确!');
}
} else {
if (Validate::checkNull($_POST['content'])) {
Tool::alertClose('警告:评论内容不得为空!');
}
if (Validate::checkLength($_POST['content'], 255, 'max')) {
Tool::alertClose('警告:评论内容长度不得大于255位!');
}
if (Validate::checkLength($_POST['code'], 4, 'equals')) {
Tool::alertClose('警告:验证码必须是四位!');
}
if (Validate::checkEquals(strtolower($_POST['code']), $_SESSION['code'])) {
Tool::alertClose('警告:验证码不正确!');
}
}
parent::__construct($this->_tpl, new CommentModel());
$_cookie = new Cookie('user');
if ($_cookie->getCookie()) {
$this->_model->user = $_cookie->getCookie();
} else {
$this->_model->user = '游客';
}
$this->_model->manner = $_POST['manner'];
$this->_model->content = $_POST['content'];
$this->_model->cid = $_GET['cid'];
$this->_model->addComment() ? Tool::alertLocation('评论添加成功,请等待管理员审核!', 'feedback.php?cid=' . $this->_model->cid) : Tool::alertLocation('评论添加失败,请重新添加!', 'feedback.php?cid=' . $this->_model->cid);
}
}
示例8: add_question
public function add_question()
{
if ($this->isPost()) {
import("@.Tool.Validate");
//验证类
$content = $_POST['content'];
//提问内容
//数据验证
if (Validate::checkNull($content)) {
parent::callback(C('STATUS_OTHER'), '提问内容不得为空');
}
$Question = D('Question');
$Question->content = $content;
$Question->user_id = $this->oUser->id;
$Question->time = time();
$Question->add() ? parent::callback(C('STATUS_SUCCESS'), '提交成功,我们会尽快回复您。') : parent::callback(C('STATUS_UPDATE_DATA'), '提交失败,请重新尝试');
}
//$this->display('Login:add_question');
}
示例9: frontadd
private function frontadd()
{
if (isset($_POST['send'])) {
if (Validate::checkNull($_POST['webname'])) {
Tool::alertBack('警告:网站名称不得为空!');
}
if (Validate::checkLength($_POST['webname'], 20, 'max')) {
Tool::alertBack('警告:网站名称不得大于二十位!');
}
if (Validate::checkNull($_POST['weburl'])) {
Tool::alertBack('警告:网站地址不得为空!');
}
if (Validate::checkLength($_POST['webname'], 100, 'max')) {
Tool::alertBack('警告:网站地址不得大于一百位!');
}
if ($_POST['type'] == 2) {
if (Validate::checkNull($_POST['logourl'])) {
Tool::alertBack('警告:Logo地址不得为空!');
}
if (Validate::checkLength($_POST['logourl'], 100, 'max')) {
Tool::alertBack('警告:Logo地址不得大于一百位!');
}
}
if (Validate::checkLength($_POST['user'], 20, 'max')) {
Tool::alertBack('警告:站长名不得大于二十位!');
}
if (Validate::checkLength($_POST['code'], 4, 'equals')) {
Tool::alertBack('警告:验证码必须是四位!');
}
if (Validate::checkEquals(strtolower($_POST['code']), $_SESSION['code'])) {
Tool::alertBack('警告:验证码不正确!');
}
$this->_model->webname = $_POST['webname'];
$this->_model->weburl = $_POST['weburl'];
$this->_model->logourl = $_POST['logourl'];
$this->_model->user = $_POST['user'];
$this->_model->type = $_POST['type'];
$this->_model->state = $_POST['state'];
$this->_model->addLink() ? Tool::alertClose('恭喜,申请友情链接成功!请等待管理员审核!') : Tool::alertBack('很遗憾,申请友情链接失败,请重试!');
}
$this->_tpl->assign('frontadd', true);
}
示例10: addComment
private function addComment()
{
if (isset($_POST['send'])) {
$_url = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
if ($_url == PREV_URL) {
if (Validate::checkNull($_POST['content'])) {
Tool::alertBack('content empty');
}
if (Validate::checkLength($_POST['content'], 255, 'max')) {
Tool::alertBack('content longer than 255');
}
if (Validate::checkEquals(strtolower($_POST['code']), $_SESSION['code'])) {
Tool::alertBack('validate code must match');
}
} else {
if (Validate::checkNull($_POST['content'])) {
Tool::alertClose('content empty');
}
if (Validate::checkLength($_POST['content'], 255, 'max')) {
Tool::alertClose('content longer than 255');
}
if (Validate::checkEquals(strtolower($_POST['code']), $_SESSION['code'])) {
Tool::alertClose('validate code must match');
}
}
parent::__construct($this->_tpl, new CommentModel());
$_cookie = new Cookie('user');
if ($_cookie->getCookie()) {
$this->_model->user = $_cookie->getCookie();
} else {
$this->_model->user = 'Guest';
}
$this->_model->manner = $_POST['manner'];
$this->_model->content = $_POST['content'];
$this->_model->cid = $_GET['cid'];
$this->_model->addComment() ? Tool::alertLocation('succeed', 'feedback.php?cid=' . $this->_model->cid) : Tool::alertLocation('failed', 'feedback.php?cid=' . $this->_model->cid);
}
}
示例11: update
private function update()
{
if (isset($_POST['send'])) {
if (Validate::checkNull($_POST['level_name'])) {
Tool::alertBack('警告:等级名称不得为空!');
}
if (Validate::checkLength($_POST['level_name'], 2, 'min')) {
Tool::alertBack('警告:等级名称不得小于两位!');
}
if (Validate::checkLength($_POST['level_name'], 20, 'max')) {
Tool::alertBack('警告:等级名称不得大于20位!');
}
if (Validate::checkLength($_POST['level_info'], 200, 'max')) {
Tool::alertBack('警告:等级描述不得大于200位!');
}
$this->_model->id = $_POST['id'];
$this->_model->level_name = $_POST['level_name'];
$this->_model->level_info = $_POST['level_info'];
$this->_model->premission = implode(',', $_POST['premission']);
$this->_model->updateLevel() ? Tool::alertLocation('恭喜你,修改等级成功!', $_POST['prev_url']) : Tool::alertBack('很遗憾,修改等级失败!');
}
if (isset($_GET['id'])) {
$_premission = new PremissionModel();
$this->_tpl->assign('AllPremission', $_premission->getAllPremission());
$this->_model->id = $_GET['id'];
$_level = $this->_model->getOneLevel();
is_object($_level) ? true : Tool::alertBack('等级传值的id有误!');
$this->_tpl->assign('id', $_level->id);
$this->_tpl->assign('level_name', $_level->level_name);
$this->_tpl->assign('level_info', $_level->level_info);
$this->_tpl->assign('prev_url', PREV_URL);
$this->_tpl->assign('update', true);
$this->_tpl->assign('title', '修改等级');
} else {
Tool::alertBack('非法操作!');
}
}
示例12: update
private function update()
{
if (isset($_POST['send'])) {
if (Validate::checkNull($_POST['name'])) {
Tool::alertBack('警告:权限名称不得为空!');
}
if (Validate::checkLength($_POST['name'], 2, 'min')) {
Tool::alertBack('警告:权限名称不得小于两位!');
}
if (Validate::checkLength($_POST['name'], 100, 'max')) {
Tool::alertBack('警告:权限名称不得大于100位!');
}
if (Validate::checkLength($_POST['info'], 200, 'max')) {
Tool::alertBack('警告:权限描述不得大于200位!');
}
$this->_model->id = $_POST['id'];
$this->_model->name = $_POST['name'];
$this->_model->info = $_POST['info'];
$this->_model->updatePremission() ? Tool::alertLocation('恭喜你,修改权限成功!', $_POST['prev_url']) : Tool::alertBack('很遗憾,修改权限失败!');
}
if (isset($_GET['id'])) {
$this->_model->id = $_GET['id'];
$_premission = $this->_model->getOnePremission();
if (!$_premission) {
Tool::alertBack('警告:不存在此权限!');
}
$this->_tpl->assign('id', $_premission->id);
$this->_tpl->assign('name', $_premission->name);
$this->_tpl->assign('info', $_premission->info);
$this->_tpl->assign('prev_url', PREV_URL);
$this->_tpl->assign('update', true);
$this->_tpl->assign('title', '修改权限');
} else {
Tool::alertBack('非法操作!');
}
}
示例13: login
public function login()
{
if (isset($_POST['send'])) {
if (Validate::checkLength($_POST['code'], 4, 'equals')) {
Tool::alertBack('validation code must be 4');
}
if (Validate::checkEquals(strtolower($_POST['code']), $_SESSION['code'])) {
Tool::alertBack('wrong validation code');
}
if (Validate::checkNull($_POST['admin_user'])) {
Tool::alertBack('username empty');
}
if (Validate::checkLength($_POST['admin_user'], 2, 'min')) {
Tool::alertBack('username less than 2');
}
if (Validate::checkLength($_POST['admin_user'], 20, 'max')) {
Tool::alertBack('username more than 20');
}
if (Validate::checkNull($_POST['admin_pass'])) {
Tool::alertBack('password empty');
}
if (Validate::checkLength($_POST['admin_pass'], 6, 'min')) {
Tool::alertBack('password less than 6');
}
$this->_model->admin_user = $_POST['admin_user'];
$this->_model->admin_pass = md5($_POST['admin_pass']);
$_login = $this->_model->getLoginManage();
if ($_login) {
$_SESSION['admin']['admin_user'] = $_login->admin_user;
$_SESSION['admin']['level_name'] = $_login->level_name;
Tool::alertLocation(null, 'admin.php');
} else {
Tool::alertBack('username or password not right');
}
}
}
示例14: update
private function update()
{
if (isset($_POST['send'])) {
if (Validate::checkNull($_POST['thumbnail'])) {
Tool::alertBack('警告:轮播图不得为空!');
}
if (Validate::checkNull($_POST['link'])) {
Tool::alertBack('警告:链接不得为空!');
}
if (Validate::checkLength($_POST['title'], 20, 'max')) {
Tool::alertBack('警告:标题不得大于20位!');
}
if (Validate::checkLength($_POST['info'], 200, 'max')) {
Tool::alertBack('警告:简介不得大于200位!');
}
$this->_model->id = $_POST['id'];
$this->_model->link = $_POST['link'];
$this->_model->thumbnail = $_POST['thumbnail'];
$this->_model->info = $_POST['info'];
$this->_model->title = $_POST['title'];
$this->_model->state = $_POST['state'];
$this->_model->updateRotatain() ? Tool::alertLocation('恭喜你,轮播器修改成功!', $_POST['prev_url']) : Tool::alertBack('很遗憾,轮播器修改失败');
}
if (isset($_GET['id'])) {
$this->_model->id = $_GET['id'];
$_rotatain = $this->_model->getOneRotatain();
if (!$_rotatain) {
Tool::alertBack('警告:不存在此轮播');
}
$this->_tpl->assign('id', $_rotatain->id);
$this->_tpl->assign('titlec', $_rotatain->title);
$this->_tpl->assign('thumbnail', $_rotatain->thumbnail);
$this->_tpl->assign('info', $_rotatain->info);
$this->_tpl->assign('link', $_rotatain->link);
$this->_tpl->assign('prev_url', PREV_URL);
$this->_tpl->assign('update', true);
$this->_tpl->assign('title', '修改轮播器');
if (empty($_rotatain->state)) {
$this->_tpl->assign('right_state', 'checked="checked"');
} else {
$this->_tpl->assign('left_state', 'checked="checked"');
}
} else {
Tool::alertBack('非法操作!');
}
}
示例15: check_data
private function check_data()
{
import("@.Tool.Validate");
//验证类
//数据验证
if (Validate::checkNull($_POST['product_id'])) {
$this->error('请选择理财产品');
}
}