2017-07-18 6 views
0

私は、ユーザーがDBに必要なすべての情報を持っているかどうかをチェックするコードを書いています。ユーザーが持っている場合は何もしませんが、空の場合はcontinueregistrationページにリダイレクトします。それはcodeigniterの壊れたURLにリダイレクト

このページでは

localhostは働いていないことを書き込みますリダイレクトする場合でも、あなたはあまりにも多くの時間をリダイレクト。クッキーをクリアしてみてください。 ERR_TOO_MANY_REDIRECTS

私のキャッシュをクリアしましたが、動作しませんでした。私はあなたが "フォームの再提出を確認" メッセージに会ったと思う

function continueregistration() { 

     //set validation rules 
     $this->form_validation->set_rules('name', 'name', 'trim|required|alpha|min_length[2]|max_length[30]'); 
     $this->form_validation->set_rules('web', 'web adress', 'trim|required|valid_url|prep_url|min_length[3]'); 
     $this->form_validation->set_rules('facebook', 'facebook adress', 'trim|valid_url|prep_url|min_length[3]'); 
     $this->form_validation->set_rules('twitter', 'twitter adress', 'trim|valid_url|prep_url|min_length[3]'); 
     $this->form_validation->set_rules('youtube', 'youtube adress', 'trim|valid_url|prep_url|min_length[3]'); 
     $this->form_validation->set_rules('instagram', 'instagram adress', 'trim|valid_url|prep_url|min_length[3]'); 
     $this->form_validation->set_rules('tel', 'telephone number', 'trim|required|alpha_numeric_spaces|min_length[3]|max_length[30]'); 
     $this->form_validation->set_rules('address', 'address', 'trim|required|alpha_numeric_spaces|min_length[3]|max_length[30]'); 
     $this->form_validation->set_rules('insdescription', 'description', 'trim|required|alpha_numeric_spaces|min_length[3]'); 

     $data['title'] = 'Continue Registration'; 
     $data['instructors'] = $this->single_instructor_model->get_instructor_info(); 

      $this->load->view('templates/header'); 
      $this->load->view('registration/registration', $data); 
      $this->load->view('templates/footer'); 

     //validate form input 
     if ($this->form_validation->run() == FALSE) 
     { 
      // fails 
      $this->load->view('templates/header'); 
      $this->load->view('registration/registration', $data); 
      $this->load->view('templates/footer'); 
     } 
     else 
     { 
      //insert the user registration details into database 
      $dataforreg = array(
       'name' => $this->input->post('name'), 
       'web' => $this->input->post('web'), 
       'fb' => $this->input->post('facebook'), 
       'twitter' => $this->input->post('twitter'), 
       'youtube' => $this->input->post('youtube'), 
       'instagram' => $this->input->post('instagram'), 
       'phone' => $this->input->post('tel'), 
       'address' => $this->input->post('address'), 
       'description' => $this->input->post('insdescription') 
      ); 

      // insert form data into database 
      if ($this->user_model->updateUser($dataforreg, $to_email)) { 
        redirect('homepage/index'); 

      } 
      else 
      { 
       // error 
       $this->session->set_flashdata('msg','<div class="alert alert-danger text-center">Error</div>'); 
        redirect('user/continueregistration'); 
      } 
     } 


    } 
+1

これはリダイレクトのループがあることを意味します –

+1

どのようなビューでそのコードを持っていますか?それは実際にコントローラの代わりになるはずです。しかし、。ビューは純粋にプレゼンテーション用です。ビジネスロジックやフロー制御は、ビュー内には存在しません。 –

+1

あなたは私がそれを呼んでいるcontinueregistration – inarilo

答えて

0

<?php 

    if($this->session->userdata('logged_in')) { 
    $query = $this->db->get_where('instructors', array('id' => $this->session->userdata('id'))); 

    $insdatacheck = $query->row_array(); 

    if($insdatacheck['name'] == '') { 
     redirect('/user/continueregistration/'); 
    } else { ?> 
     <script type="text/javascript">alert('hello');</script> 
     <?php 
    } 

    } 

?> 

とコントローラ:ここに私の見解です。あなたのユーザーが利用できないときに起こります。それはユーザ/継続登録に向けられ、リフレッシュせずにリダイレクトするだけでデータをdatebaseに送り、リダイレクトを続行します。これにより、redirect( 'link'、 'refresh');を設定する必要があります。クリックされた場合は送信ボタンを確認し、その中で操作を実行します。

if(isset($_POST['submit'])   //button with the name "submit" 
{ 
    //action 
} 
+0

実際にはフォームではありません。単なるページです –

関連する問題