<?php
namespace app\index\controller;
use think\facade\View;
use think\facade\Request;
use think\facade\Session;

class Form extends Base{
	
    public function insert(){
		IS_AJAX(Request::isAjax());
		$tdata=Request::param();
		
		//表1
		if($tdata['table']=='form_content1'){
			if(trim($tdata['name'])==''){
				$data =['type' =>1,'msg' =>'Please fill in your name!'];
				return json($data);
			}
			
			if(strlen($tdata['phone'])!="11"){
			$data =['type' =>1,'msg' =>'Please fill in the correct mobile phone number!'];
			return json($data);
		    }

			if(!filter_var($tdata['mail'], FILTER_VALIDATE_EMAIL)) {
				$data =['type' =>1,'msg' =>'Please fill in the correct email address!'];
				return json($data);
			}
	
			if(trim($tdata['description'])==''){
				$data =['type' =>1,'msg' =>'Please enter the content you want to consult!'];
				return json($data);
			}	
		}
		
		//插入数据
		$id=\app\index\model\Form::insert();
		$data =['type' =>'ok','msg' =>'Submitted successfully!'];
		return json($data);
	
	}

}
