我认为这可能是本地服务器问题,因为代码没有问题。如果有人能看一看,将不胜感激!!
控制器:
<?php
class Form1 extends CI_Controller {
function index() {
$this->load->view('myform1');
}
function save(){
$this->load->model('form1_model');
if($this->input->post('submit')){
$this->form1_model->process();
}
redirect('formsuccess1');
}
}
?>
模型:
<?php
class Form1_model extends CI_Model {
function process(){
$password = $this->input->post('pass_word');
$passconf = $this->input->post('password_confirm');
$email = $this->input->post('e_mail');
$data = array(
'password'=>$password,
'passconf'=>$passconf,
'email'=>$email
);
$this->db->insert('formdata',$data);
}
}
?>
看法:
<html>
<head>
<title>My Form</title>
</head>
<body>
<?php echo form_open('form1/save', array('name' => 'myform')); ?>
<h5>Password</h5>
<?php echo form_error('password'); ?>
<input type="text" name="password"/>
<h5>Password Confirm</h5>
<?php echo form_error('passconf'); ?>
<input type="text" name="passconf"/>
<h5>Email Address</h5>
<?php echo form_error('email'); ?>
<input type="text" name="email"/>
<div><input type="submit" name="submit" value="Submittt" /></div>
</form>
</body>
</html>