2016-04-26 94 views
3

我是codeigniter中的新成員。Url在重定向時更改codeigniter

我試圖開發登錄頁面,它幾乎完成,但我不知道當我試圖成功登錄後重定向頁面或重定向後未成功登錄,url localhost:81的開始部分更改爲[::1]。我不知道爲什麼它發生我谷歌它,但我沒有得到正確的方式,所以請有人幫我下面我已經提到我的代碼。

預先感謝您。


這是控制器代碼來驗證電子郵件和密碼

<?php 
defined('BASEPATH') OR exit('No direct script access allowed'); 

class verifyLogin_controller extends CI_Controller { 

function _construct(){ 
    parent::_construct();  
} 

public function index() 
{  

    if($_POST["submitLogin"]) 
    { 
     $userEmail=$this->input->post('email'); 
     $password=$this->input->post('password'); 

     $verify_query = $this->db->from("admin");   
     $verify_query = $this->db->where(array("admin_userid" => $userEmail,"admin_password"=>$password)); 
     $verify_query = $this->db->limit(1); 
     $res=$this->db->get()->result();    
     if($res != null) 
     { 

      redirect("homeHeader_controller/index"); 

     } 
     else 
     { 

      redirect("adminLogin_controller/index"); 

     } 

    } 
} 
} 
+0

爲什麼使用81端口而不是80端口? –

+0

,因爲在我的系統中,我也使用IIS服務器,所以 –

回答

2

設置你的BASE_URL

$config['base_url'] = 'http://localhost:81/'; 
+0

謝謝你和設置base_url後如何使用 –

1

剛剛嘗試添加以下代碼:

$ark_root = "http://".$_SERVER['HTTP_HOST']; 
$ark_root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']); 
$config['base_url'] = $ark_root;