2016-07-31 112 views
0

我遇到了没有工作重定向在我的方法之一。但其余的重定向工作。 顺便说一句,在我的本地主机,重定向工作,但是当我把它放在我的网站来测试它。它没有传递给该重定向,而是留在了signup_validation中,并且仍然在我的电子邮件中收到了电子邮件验证。Codeigniter重定向不在网站工作

public function signup_validation() { 

    $account = array(
     'email' => strip_tags($this->input->post('email')), 
     'password' => sha1($this->input->post('password')), 
     'firstname' => strip_tags($this->input->post('firstname')), 

     'lastname' => strip_tags($this->input->post('lastname')), 
     'contact_number' => $this->input->post('contact_number'), 
     'home_address' => strip_tags($this->input->post('home_address')), 

     'gender' => $this->input->post('gender'), 

     'g-recaptcha-response' => $this->input->post('g-recaptcha-response') 
    ); 

    $this->form_validation->set_rules('email', 'Email', 'required|valid_email|is_unique[account.email]'); 
    $this->form_validation->set_rules('password', 'Password', 'required|min_length[6]|max_length[32]'); 
    $this->form_validation->set_rules('cpassword', 'Confirm Password', 'required|matches[password]'); 
    $this->form_validation->set_rules('firstname', 'First name', 'required|callback_alpha_dash_space'); 
    $this->form_validation->set_rules('lastname', 'Last name', 'required|callback_alpha_dash_space'); 
    $this->form_validation->set_rules('contact_number', 'Contact Number', 'required|callback_number|min_length[7]|max_length[11]'); 
    $this->form_validation->set_rules('gender', 'Gender', 'required'); 
    $this->form_validation->set_rules('home_address', 'required|callback_address'); 
    $this->form_validation->set_rules('tac', 'Terms and Condition', 'required'); 
    $this->form_validation->set_rules('g-recaptcha-response', 'Recaptcha', 'required'); 

    $this->form_validation->set_message('number', 'The %s must be a number'); 
    $this->form_validation->set_message('address','The %s must contain only letters, period, comma, spaces and dash.'); 
    $this->form_validation->set_message('is_unique', 'Email address is already used.'); 
    $this->form_validation->set_message('alpha_dash_space','The %s must contain only letters, period, spaces, and dash.'); 

    if ($this->form_validation->run() == FALSE) { 
     $this->register(); 
    } else { 
     $recaptcha = $this->input->post('g-recaptcha-response'); 
      if (!empty($recaptcha)) { 
       $response = $this->recaptcha->verifyResponse($recaptcha); 
       if (isset($response['success']) and $response['success'] === true) { 
        $this->MainModel->add_account(); 
        redirect('main/email_sent', 'refresh');  
       } 
      } 

    } 
} 

回答

0

删除的redirect()第二个参数,设置第二个参数'refresh'这种方法只是刷新当前页面时。

redirect('main/email_sent'); 
+0

我试过了,当我按下注册按钮时,它会在base_url()。main/signup_validation中存储,并且它不会继续重定向。以及即时通讯工作在localhost重定向工程。 – erinr

+0

@EdgarOng试着''回声'你通过的'uri'并且在'redirect'的定义中'echo'之后死掉脚本,看看你打印的URL是否是你传入的。 –

0

redirect('main/email_sent', 'refresh'); 

太兴奋删除第二个参数( '刷新')知道,如果它的工作原理。

+0

它也有一段时间以前和悲伤地说,仍然工作。 – erinr