[eluser]kruse[/eluser]
Hello,
This is a function to create a new user. It works perfectly fine offline on PHP5
but online on my server PHP4 it does not display validation errors on the form!
What can be wrong? I searched for hours : ) Please check the code.
Code:
function do_signup()
{
///////////////////////////////////////////////////////////
//
// Get the language from the settings
//
///////////////////////////////////////////////////////////
$language = $this->config->item('site_language');
///////////////////////////////////////////////////////////
//
// Load the language files
//
///////////////////////////////////////////////////////////
$this->lang->load('signup', $language);
///////////////////////////////////////////////////////////
//
// Load the validation library
//
///////////////////////////////////////////////////////////
$this->load->library('validation');
///////////////////////////////////////////////////////////
//
// Validate the input
//
///////////////////////////////////////////////////////////
$rules['forname'] = "required|min_length[2]";
$rules['lastname'] = "required|min_length[2]";
$rules['email'] = "required|valid_email";
$rules['username'] = "required|callback_username_check";
$rules['password'] = "required|min_length[5]";
$this->validation->set_rules($rules);
///////////////////////////////////////////////////////////
//
// Set the validation items
//
///////////////////////////////////////////////////////////
$fields['forname'] = $this->lang->line('signup_forname');
$fields['lastname'] = $this->lang->line('signup_lastname');
$fields['email'] = $this->lang->line('signup_email');
$fields['username'] = $this->lang->line('signup_username');
$fields['password'] = $this->lang->line('signup_password');
$this->validation->set_fields($fields);
$this->validation->set_error_delimiters('<div class="field_error">', '</div>');
///////////////////////////////////////////////////////////
//
// Process the incoming fields
//
///////////////////////////////////////////////////////////
if ($this->validation->run() == FALSE)
{
///////////////////////////////////////////////////////////
//
// Get the language from the settings
//
///////////////////////////////////////////////////////////
$language = $this->config->item('site_language');
///////////////////////////////////////////////////////////
//
// Load the language file
//
///////////////////////////////////////////////////////////
$this->lang->load('navigation', $language);
$this->lang->load('signup', $language);
///////////////////////////////////////////////////////////
//
// Display the errors
//
///////////////////////////////////////////////////////////
$this->load->view('signup');
} else {
///////////////////////////////////////////////////////////
//
// Put the incoming date in variables
//
///////////////////////////////////////////////////////////
$pass = $_POST['password'];
$pass = dohash($pass,'md5');
$data = array(
'forname' => $_POST['forname'] ,
'lastname' => $_POST['lastname'] ,
'email' => $_POST['email'] ,
'username' => $_POST['username'] ,
'password' => $pass ,
'points' => 0 ,
'status' => 1
);
///////////////////////////////////////////////////////////
//
// Save the new post
//
///////////////////////////////////////////////////////////
$this->db->insert('profiles', $data);
///////////////////////////////////////////////////////////
//
// Redirect to previous page
//
///////////////////////////////////////////////////////////
redirect('login/form');
}
}