如何在Codeigniter中从一页重定向到另一页 [英] How to redirect from one page to another page in codeigniter
本文介绍了如何在Codeigniter中从一页重定向到另一页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不知道如何实现这种代码点火器概念.
如果单击链接,如何将页面重定向到另一页面?
I'm not getting how to do this codeignitor concept.
How to redirect one page to another page if I click the link?
Main1.php
Main1.php
<?php
class Main1 extends CI_Controller {
public function index() {
//Load the URL helper
$this->load->helper('url');
//Redirect the user to some site
redirect('http://localhost/CodeIgniter/index.php/Main');
$this->load->view('test1');
}
}
?>
test1.php
test1.php
<!DOCTYPE html>
<html>
<head>
<title>view page</title>
</head>
<body style="padding-top:50px; padding-left:300px">
<h1 style="color:red"> Without Extension </h1>
<a href="">Visit With Extension Example</a>
</body>
</html>
Main.php
<?php
class Main extends CI_Controller {
public function index() {
$this->load->view('test.html');
}
}
?>
test.html
test.html
<!DOCTYPE html>
<html>
<head>
<title>view page</title>
</head>
<body style="padding-top:50px; padding-left:300px">
<h1 style="color:red"> With Extension </h1>
</body>
</html>
推荐答案
您可以使用 redirect();
如下所示.
redirect('controllerName/methodName','refresh');
或如果要在同一控制器中重定向.
OR if you want to redirect in same controller.
$this->methondName;
您的代码应该是这样
<?php
class Main1 extends CI_Controller {
public function index() {
//Load the URL helper
$this->load->helper('url');
//Redirect the user to some site
redirect('Main/index','refresh');
}
}
?>
这篇关于如何在Codeigniter中从一页重定向到另一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文