这是我的视图文件(registration_view.php)
<?php echo form_open("user/registration"); ?>
<p>
<label for="first_name">First Name:</label>
<input type="text" id="first_name" name="first_name" value="<?php echo set_value('first_name'); ?>" />
</p>
<p>
<label for="last_name">Last Name:</label>
<input type="text" id="last_name" name="last_name" value="<?php echo set_value('last_name'); ?>" />
</p>
<p>
<label for="email">Email Address:</label>
<input type="text" id="email" name="email" value="<?php echo set_value('email'); ?>" />
<p>
<label for="pickup_address">Pick up Address:</label>
<input type="text" id="pickup_address" name="pickup_address" value="<?php echo set_value('pickup_address'); ?>" />
</p>
<p>
<label for="postal_code1">Postal code:</label>
<input type="text" id="postal_code1" name="postal_code1" value="<?php echo set_value('postal_code1'); ?>" />
</p>
<p>
<input type="submit" class="greenButton" value="Submit" />
</p>
<?php echo form_close(); ?>
我的控制器 user.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class User extends CI_Controller{
function __construct() {
parent::__construct();
$this->load->model('user_model');
}
public function index()
{
$this->load->view('registration_view');
}
public function registration()
{
$this->user_model->add_registration();
}
}
模型(user_model.php)
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
*
*/
class User_model extends CI_Model {
function __construct()
{
parent::__construct();
}
public function add_registration()
{
$data=array(
'first_name'=>$this->input->post('first_name'),
'last_name'=>$this->input->post('last_name'),
'email'=>($this->input->post('email'),
'pickup_address'=>$this->input->post('pickup_address'),
'postal_code1'=>$this->input->post('postal_code1'),
);
$this->db->insert('user',$data);
}
}
这是我的应用程序。它是工作。我需要将此视图与两个视图分开。名字、姓氏和电子邮件属于 one_view.php,其他属于另一个视图(second_view.php)。单击 one_view.php 文件中的下一步按钮,然后打开 second_view.php 而不将值转到数据库。然后如果单击 second_view.php 中的提交按钮,所有值都会传递给用户表...请帮助我如何使用 ajax 或 jquery 分离视图文件。