2016-07-31 89 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