[英]How to redirect page and show message when php error on codeigniter?
我想重定向頁面然后在codeigniter上顯示php錯誤時顯示一條消息,該怎么做?
這里是我的php 錯誤示例
遇到PHP錯誤嚴重性:錯誤消息:調用成員函數GetToken()on null文件名:operator_pt / Profil_operatorpt.php行號:95 Backtrace:
編輯:從kuldep請求來自控制器的代碼
public function testkoneksi()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('username','Username','trim|required');
$this->form_validation->set_rules('password','Password','required');
$this->form_validation->set_rules('url','URL','required');
if($this->form_validation->run()===FALSE)
{
$this->session->set_flashdata('category_success', 'ISI DATA DENGAN BENAR.');
redirect('operator_pt/profil_operatorpt', 'refresh');
}
else
{
$this->load->helper('url');
$this->load->library("Nusoap_lib");
$url = $_POST["url"];
//$url = 'http://localhost:8082/ws/live.php?wsdl';
$client = new nusoap_client($url, true);
$proxy = $client->getproxy();
//mendapatkan token
$username = $_POST["username"];
$password = $_POST["password"];
$url = $_POST["url"];
$result=$proxy->GetToken($username, $password);
$token = $result;
if (isset($token)) {
$this->session->set_flashdata('token_sukses', 'KONEKSI DENGAN FEEDER TELAH SUKSES.');
redirect('operator_pt/profil_operatorpt', 'refresh');
}
else $this->session->set_flashdata('token_gagal', 'KONEKSI DENGAN FEEDER GAGAL, CEK ULANG USERNAME, PASSWORD & URL-NYA.');
redirect('operator_pt/profil_operatorpt', 'refresh');
}
}
$response = array('status' => true, 'message' => 'Error', 'redirect' => base_url() . 'Path to redirect');
header('Content-Type:application/json');
echo json_encode($response);
這可能有效。 提供錯誤消息以代替“錯誤”。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.