一旦用户注册表单成功后,谁能帮我提供简单的解决方案来重定向页面。
我的控制器代码:
public function signup()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('user_name','Name','trim|required|min_length[4]xss_clean');
$this->form_validation->set_rules('signupemail','Email','trim|required|valid_email');
$this->form_validation->set_rules('password','Password','trim|required|min_length[8]xss_clean');
$this->form_validation->set_rules('confmpassword','Password Confirmation','trim|required|matches[password]');
$this->form_validation->set_rules('contactno','Contact No','trim|required');
if ($this->form_validation->run()) {
// $this->welcome_model->InsertStudents();
echo json_encode("Thank You, Successfully Completed");
//$this->welcome();
} else {
$val = array(
'name' => form_error('name'),
'email' => form_error('email'),
'password' => form_error('password'),
'confirmpassword' => form_error('confmpassword'),
'contactno' => form_error('contactno')
);
echo json_encode(validation_errors());
}
}
阿贾克斯代码:
$(document).ready(function(){
$('#message').hide();
$('form').submit(function(){
//alert('ok');
$.ajax({
url:this.action,
type:this.method,
data:$(this).serialize(),
success:function(data){
var obj = $.parseJSON(data);
$('#message').show();
if(obj['name']!=null)
{
$('#message').text("");
$('#message').append(obj1);
$('#message').html(obj['name']);
$('#message').append(obj['email']);
$('#message').append(obj['password']);
$('#message').append(obj['confirmpassword']);
$('#message').append(obj['contactno']);
}
else
{
$('#message').text("");
$('#message').html(obj);
}
},
erro:function(){
alert("Please Try Again");
}
});
return false;
});
});