addElement('header', get_lang('CourseRequiresPassword')); $form->addElement('hidden', 'course_id', $courseId); $form->addElement('hidden', 'session_id', $sessionId); $form->addElement('password', 'course_password', get_lang('Password')); $form->addButtonSave(get_lang('Accept')); if ($form->validate()) { $formValues = $form->exportValues(); if (sha1($formValues['course_password']) === $courseInfo['registration_code']) { Session::write('course_password_'.$courseInfo['real_id'], true); header('Location: '.api_get_course_url($courseInfo['code'], $sessionId). '&action=subscribe&sec_token='.Security::get_existing_token()); exit; } else { Display::addFlash( Display::return_message(get_lang('CourseRegistrationCodeIncorrect'), 'error') ); } } $tpl = new Template(null); $tpl->assign('content', $form->toHtml()); $tpl->display_one_col_template();