欢迎来到路由器窝!
极致表单判断电话邮箱

极致表单判断电话邮箱

浏览次数:

作者: 路由器窝

信息来源: www.zngps.com

更新日期: 2020-10-28 16:04

文章简介

//判断文件\Home\c\MessageController.php?phpnamespace Home\c;use FrPHP\lib\Controller;use FrPHP\Extend\Page;class MessageController extends CommonController{function index(){if($_POST){$w = $this-frparam();$w = get_fields_data($w,message,0)

  • 正文开始
  • 相关文章
//判断文件\Home\c\MessageController.php
<?php

namespace Home\c;

use FrPHP\lib\Controller;
use FrPHP\Extend\Page;

class MessageController extends CommonController
{

	function index(){
		
		if($_POST){
			
			$w = $this->frparam();
			$w = get_fields_data($w,'message',0);
			
			$w['body'] = $this->frparam('body',1,'','POST');
			$w['user'] = $this->frparam('user',1,'','POST');
			$w['tel'] = $this->frparam('tel',1,'','POST');
			$w['aid'] = $this->frparam('aid',0,0,'POST');
			$w['tid'] = $this->frparam('tid',0,0,'POST');
			$w['email'] = $this->frparam('email',1,'','POST');
			$w['orders'] = 0;
			$w['istop'] = 0;
			$w['hits'] = 0;
			
			if($this->webconf['autocheckmessage']==1){
				$w['isshow'] = 1;
			}else{
				$w['isshow'] = 0;
			}
			
			$w['ip'] = GetIP();
			$w['addtime'] = time();
			if(isset($_SESSION['member'])){
				$w['userid'] = $_SESSION['member']['id'];
			}else{
				$w['userid'] = 0;
			}
			
			if($w['email']==''){
				//$this->error('姓名不能为空!');
				if($this->frparam('ajax')){
					JsonReturn(['code'=>1,'msg'=>'The mailbox cannot be empty!']);
				}
				Error('The mailbox cannot be empty!');
			}	
			
			
			
			$w['title'] = $this->frparam('title',1);
			//仅在存在手机号的情况进行检测手机号是否有效-可自由设置
			if($w['email']!=''){
               if(!preg_match("/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/",$w['email'])){  
					//$this->error('Email format is not correct!');
					if($this->frparam('ajax')){
						JsonReturn(['code'=>1,'msg'=>'Email format is not correct!']);
					}
					Error('Email format is not correct!');
				}
				
			}
			
			if($this->frparam('title',1,'','POST')==''){
				//$this->error('标题不能为空!');
				if($this->frparam('ajax')){
					JsonReturn(['code'=>1,'msg'=>'name cannot be empty!']);
				}
				Error('name cannot be empty!');
			}

						if($w['body']==''){
				//$this->error('姓名不能为空!');
				if($this->frparam('ajax')){
					JsonReturn(['code'=>1,'msg'=>'Amazon Order cannot be empty!']);
				}
				Error('Amazon Order cannot be empty!');
			}
			
			
			
			
			if(!isset($_SESSION['message_time'])){
				$_SESSION['message_time'] = time();
				$_SESSION['message_num'] = 0;
			}
			
			if(($_SESSION['message_time']+10*60)<time()){
				$_SESSION['message_num'] = 0;
				$_SESSION['message_time'] = time();
			}
			$_SESSION['message_num']++;
			if($_SESSION['message_num']>5 && ($_SESSION['message_time']+10*60)>=time()){
				if($this->frparam('ajax')){
					JsonReturn(['code'=>0,'msg'=>'You operate too frequently, please try again in 10 minutes!']);
				}
				Error('You operate too frequently, please try again in 10 minutes!');
			}
			
			
			$res = M('message')->add($w);
			if($res){
				if($this->frparam('ajax')){
					JsonReturn(['code'=>0,'msg'=>'Submitted successfully! We will get back to you as soon as possible!','url'=>get_domain()]);
				}
				Success('Submitted successfully! We will get back to you as soon as possible!',get_domain());
			}else{
				if($this->frparam('ajax')){
					JsonReturn(['code'=>1,'msg'=>'Failed to submit. Please try again!']);
				}
				//$this->error('提交失败,请重试!');
				Error('Failed to submit. Please try again!');
			}
			
			
			
		}
		

		
	}
}

转载请注明:极致cms» 极致表单判断电话邮箱

标签:
  • 极致表单判断电话邮箱
    阅读
    //判断文件\Home\c\MessageController.php?phpnamespace Home\c;use FrPHP\lib\Controller;use FrPHP\Extend\Page;class MessageController extends CommonController{function index(){if($_POST){$w = $this-frparam();$w = get_fields_data($w,message,0)
上一篇:没有了
下一篇:没有了
最近更新作品