简体   繁体   English

Codeigniter重定向在网站中不起作用

[英]Codeigniter redirect not working in website

i have encountered not working redirect in one of my method. 我遇到了一种方法无法正常工作的重定向。 but the rest redirect is working. 但其余重定向仍在工作。 by the way in my localhost that redirect is working but when i put it in my site to test it. 顺便说一下,在我的本地主机中,重定向工作正常,但是当我将其放在站点中进行测试时。 it did not pass to that redirect instead it stayed in signup_validation and still received email verification in my email. 它没有传递到该重定向,而是停留在signup_validation中,并且仍在我的电子邮件中收到了电子邮件验证。

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');     
                }
            }

    }
}

删除redirect()的第二个参数,当将第二个参数设置为'refresh'此方法将仅刷新当前页面。

redirect('main/email_sent');

remove second parameter ('refresh') from 从中删除第二个参数(“刷​​新”)

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

Just Excited to know if it works. 只是兴奋地知道它是否有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM