next up previous
Next: Student-Menu Up: No Title Previous: Printing HTML Tables

Processing HTML Forms

Two procedures to process a HTML form:

Forms can have the following types of elements:

procedure get_access as
begin
   htp.htmlOpen;
   htp.headOpen;
   htp.title('Get password');
   htp.header(1, 'Grade Book Access Page');
   htp.headClose;
   htp.bodyOpen;
   htp.formOpen(owa_util.get_owa_service_path ||
                'user_access.start_session');
   htp.print('Today is ' || 
             to_char(sysdate, 'Day') || '  ' || 
             to_char(sysdate, 'Dd / Mon / YYYY HH:MI AM'));
   htp.nl;

   htp.tableOpen;
   htp.tableRowOpen;
   htp.tableData(htf.strong('USER ID: '));
   htp.tableData(htf.formText('usid', 20, 50));
   htp.tableRowClose;
   htp.tableRowOpen;
   htp.tableData(htf.strong('PASSWORD: '));
   htp.tableData(htf.formPassword('passwd', 20, 50));
   htp.tableRowClose;
   htp.tableClose;

   htp.formSubmit(NULL, ' Proceed ');
   htp.formReset;
   htp.formClose;
   htp.bodyClose;
   htp.htmlClose;
Exception
   when others then
      htp.print('error in user_access.get_access');
end get_access;

procedure start_session(usid in varchar2   DEFAULT NULL,
                        passwd in varchar2 DEFAULT NULL) as
   user_buffer     varchar(15);
   passwd_buffer   varchar(15);
   time_buffer     date;
   auth_buffer     varchar(15);
   random_num     varchar(10);
   access_buffer  varchar2(30);
   bad_passwd     exception;
begin
   select A.userid, A.password, A.lastAccess, A.authority
   into   user_buffer, passwd_buffer, time_buffer, 
          auth_buffer
   from   users A
   where  upper(A.userid)=upper(start_session.usid);

   if start_session.passwd != passwd_buffer then
      raise bad_passwd;
   end if;
   random_num := to_char(sysdate, 'SSSSS');
   access_buffer := user_buffer || ',' || random_num;
   update users
   set u_access = access_buffer,
       lastAccess = sysdate
   where users.userid=user_buffer;
   commit;
   menus.teacher_menu(access_buffer);
Exception
   when bad_passwd then
      htp.print('Bad password ');
   when no_data_found then
      htp.print('Invalid user');
   when others then
      htp.print('Error in user_access.start_session');
end start_session;

create table users (
   userid     varchar2(15),
   password   varchar2(15),
   lastaccess date,
   u_access   varchar(30), -- coded string
   authority  varchar2(15) -- TEACHER/STUDENT
);



Dr. Raj Sunderraman
6/23/1998