2013-04-28 89 views
1

我是codeigniter的新手。我正在開發一個工作網站。我搜索一份工作,然後找到合適的工作,然後當點擊工作細節時,如果用戶登錄,則立即應用按鈕出現,但如果用戶沒有登錄,那麼登錄或註冊按鈕出現。我需要做的是點擊登錄或註冊完成後,他們需要重定向到他們搜索的同一頁面。我怎麼能在cdeigniter中做到這一點?登錄或註冊後重定向到上一頁

我的工作詳細頁面

public function details($slug = NULL) 
{ 
    $this->load->model('jobmodel'); 
    $this->load->helper('job'); 
    $slug = $this->uri->segment(3); 
    $jobID = $this->jobs_model->getJobidFromSlug($slug); 
    $userID = $this->session->userdata('user_id'); 
    $check = $this->jobs_model->checkAppliedJob($userID, $jobID); 
    $data['check'] = $check; 

    // #common head section 

    $data['site_title'] = 'Job By Country | Neev '; 
    $data['site_keywords'] = 'job,dubai,hr,portal'; 
    $data['site_description'] = 'Neev Home, Hr Portal, Job '; 
    $join = 'LEFT JOIN job_industry AS ji ON(ji.id = ejp.job_industry) LEFT JOIN job_country AS jc ON (ejp.country_id = jc.id) 
       LEFT JOIN job_category AS jcat ON (ejp.job_category = jcat.id)where ejp.slug ="' . $slug . '"'; 
    $jobsDetails = Jobmodel::find(array(
     'select' => 'ejp.*,ji.title as industry_type,jc.title as country,jcat.title as category', 
     'from' => 'employer_job_posting as ejp', 
     'joins' => $join 
    )); 

    // echo Jobmodel::connection()->last_query; 
    // die; 

    $data['main_content'] = 'jobFulldetails'; 
    $data['jobs'] = $jobsDetails; 
    $this->load->view($this->jobView, $data); 
} 

回答

1

您可以添加此邏輯保持在一個會話瀏覽上一頁。一旦你登錄或註冊獲取該會話變量的值重定向到該頁面。像這樣

header("location:$_SESSION['prev_page']"); 
0

這對我的作品

<script type="text/javascript"> 
     var back = document.referrer; 
     window.location.replace(back); 
</script> 
+0

這對我有用。謝謝您的幫助。 – soulpower 2013-04-29 04:48:07

相關問題