Files
spacestation/home/controllers/h5/paic/Reg.php
T
2025-03-12 10:34:24 +08:00

62 lines
1.9 KiB
PHP

<?php
defined('BASEPATH') or exit('No direct script access allowed');
require_once 'Base.php';
class Reg extends Base
{
public function __construct()
{
parent::__construct();
$this->white_login_method = ['index'];
}
public function index()
{
if ($this->input->is_ajax_request()) {
$redis = &load_cache('redis');
$code = $this->input->post('code');
$name = $this->input->post('name');
$mobile = $this->input->post('mobile');
$province_id = $this->input->post('province_id');
$city_id = $this->input->post('city_id');
$belong_to = $this->input->post('belong_to');
$cache_key = "paic_reg_code_" . $mobile;
if (!$name) {
$this->fail('', '请填写真实姓名');
}
if (!$mobile || !mobile_valid($mobile)) {
$this->fail('', '请输入正确的手机号');
}
if (!$province_id || !$city_id) {
$this->fail('', '请选择省市');
}
if (!strlen($belong_to)) {
$this->fail('', '请选择归属');
}
if (!$code || $code != $redis->get($cache_key)) {
$this->fail('', '请输入正确的验证码');
}
$add = array(
'name' => $name,
'mobile' => $mobile,
'province_id' => $province_id,
'city_id' => $city_id,
'belong_to' => intval($belong_to),
);
$req = $this->user_model->add($add);
if (!$req) {
$this->fail('', '注册失败');
}
$redis->delete($cache_key);
$this->success('', '注册成功');
} else {
$data['belong_to_list'] = App_paic_users_model::BELONG_TO_LIST;
$this->load->view('h5/paic/reg', $data);
}
}
}