【发布时间】:2021-10-16 10:40:15
【问题描述】:
我正在 Codeigniter 中创建电子商务。这是用于注册的控制器文件:
class Register extends CI_Controller {
public function index()
{
$this->load->view('common/header');
$this->load->view('register');
$this->load->view('common/footer');
}
public function home(){
$this->load->view('common/header');
$this->load->view('common/slider');
$this->load->view('home');
$this->load->view('common/footer');
}
public function signup(){
$username = $this->input->post("username");
$password = $this->input->post("password");
$email = $this->input->post("email");
$this->form_validation->set_rules('username','User Name','required|is_unique[user.name]|min_length[4]');
$this->form_validation->set_rules('password','Password','required|min_length[5]');
$this->form_validation->set_rules('email','Email address','required|valid_email');
$this->form_validation->set_error_delimiters('<div class="text-danger">', '</div>');
if($this->form_validation->run() == true){
$this->load->model('register_model');
if($this->register_model->register_user($username,$password,$email)){
$this->home();
}else{
$this->index();
}
}else{
$this->index();
}
}
}
在表单提交页面重定向到主页,但浏览器上的 URL 是 (http://localhost:8080/codignitor_projects/shophere/register/signup) 但我想将 URL 更改为此 (http: //localhost:8080/codignitor_projects/shophere/)
【问题讨论】:
标签: php codeigniter