表单留言的时候手机号重复可以正常判断 IP地址重复就判断不了的 帮忙看 一下是哪里出了错。 _Home_List(); } public function show() { $this->_Home_Show(); } public function post() { if (IS_POST) { // 这里表示提交之前 $post = \Phpcmf\Service::L('input')->post('data'); // 假设手机号码的字段名是 'tel' if (!isset($post['tel']) || !preg_match('/^1[3-9]\d{9}$/', $post['tel'])) { $this->_json(0, '手机号码格式不正确'); } if (\Phpcmf\Service::M()->table($this->init['table']) ->where('tel', $post['tel'])->counts() > 0) { $this->_json(0, '请不要重复提交 谢谢支持!'); } // 获取用户的 IP 地址 $ip = \Phpcmf\Service::L('input')->ip_address(); // 检查 IP 地址是否已经存在 if (\Phpcmf\Service::M()->table($this->init['table']) ->where('inputip', $ip) ->counts() > 0) { $this->_json(0, 'IP重复!'); } // 如果 IP 不重复,则继续执行后续代码 // 如果手机号码和标题的验证都通过,则继续处理表单数据... } $this->_Home_Post(); } }