I want to redirect a page and then show a message when a php error show on codeigniter, how to do that ?
here my php error example
A PHP Error was encountered Severity: Error Message: Call to a member function GetToken() on null Filename: operator_pt/Profil_operatorpt.php Line Number: 95 Backtrace:
Edit : Request from kuldep here my code from controller
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);
This may work. Give your error message in place of 'Error'.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.