addElement('header', get_lang('CourseRequiresPassword')); $form->addElement('hidden', 'course_id', $course_id); $form->addElement('hidden', 'session_id', $session_id); $form->addElement('password', 'course_password', get_lang('Password')); $form->addButtonSave(get_lang('Accept')); if ($form->validate()) { $form_values = $form->exportValues(); if (sha1($form_values['course_password']) === $course_info['registration_code']) { Session::write('course_password_'.$course_info['real_id'], true); header('Location: '.api_get_course_url($course_info['code'], $session_id)); exit; } else { $tpl->assign('error_message', Display::display_error_message(get_lang('CourseRegistrationCodeIncorrect'), true, true)); } } $tpl->assign('form', $form->toHtml()); $content = $tpl->get_template('auth/set_temp_password.tpl'); $tpl->assign('content', $tpl->fetch($content)); $tpl->display_one_col_template();