I am a total php beginner. I actually want to customize a survey platform for visual stimuli for my needs as I need this for my thesis. The original version of this survey platform asks participants for their mail address to login then they see the available tests. As far as I understand it the code checks if the mail address is already saved in the database and if not reserves a certain number of the stimuli for the respective participant (with the use of their mail address as identifier). This number of stimuli will then be blocked from further tests. This however poses to problems:
1) participants can just participate once 2) participants have to give up their anonymity
The whole thing doesn't have to be very sophisticated. It would be sufficient if participants could log in with the word "anonymous" and then come to available tests where a certain number of stimuli is reserved not by their mail address but i.e. by an automatically produced unique random number which serves as an identifier.
I think the important lines of code are the following:
/**
* Lets user login. Stores new e-mail addresses if not yet in database.
*/
function login() {
$this->validation->set_error_delimiters('<div class="error">', '</div>');
$this->validation->set_message('required', $this->lang->line("validation_error_validemail_required"));
$this->validation->set_message('valid_email', $this->lang->line("validation_error_validemail_required"));
// check if valid e-mail address
//required|valid_email
$rules['email'] = "required|valid_email";
$this->validation->set_rules($rules);
$fields['email'] = $this->lang->line("frontend_user_email");
$this->validation->set_fields($fields);
if ($this->validation->run() == FALSE) {
$this->load->view('welcome_message'); // reload form
} else {
$this->load->model("testcontainer_model", 'testcontainer');
$this->data['testcontainer']->activeuser = $this->data['testcontainer']->getUserByEmail($_POST['email']);
$this->load->view('welcome_message', $this->data);
}
}
/**
* Logout user, unset session data.
*/
function logout() {
$this->session->unset_userdata('user_email');
$this->session->unset_userdata('user_id');
$this->session->unset_userdata('albumpath_relative');
$this->session->unset_userdata('test_name');
$this->session->unset_userdata('test_id');
$this->load->view('welcome_message');
}
Would you please be so nice to help me modifying this code to get what I want want? I am grateful for every help!
Best regards,
Andreas
Forms in CI can be complex. This can be a very helpful tool if you wan to save some time too: http://formigniter.org/app/index.php/formigniter/index/5