In all cases the code can not find the data in the database even if it
exists;
the redirect is not executed;
also may be the request.args(0)  logic is wrong. Any help on this,
those experienced web2py users

On Oct 29, 7:03 am, dbb <debe...@yahoo.com> wrote:
> I have the following data structure, what I want is the following:
> if the data entered is not in the database to enter it, then redirect
> to student
> information to enter the new data for the student. Once the data is
> in, the next time I enter the same data,the program compares the
> student ID in the database and if a match is
> found  I want the data to display.
> But this code is not doing that, need help on this
>
> ###############################################################
> database for a student############################
> db.define_table('student',
>              Field('first_name'),
>              Field('middle_initial'),
>              Field('last_name'),
>              Field('student_ID'),
>              Field('student_address'),
>              Field('student_phone'),
>              Field('student_email'))
>
> db.define_table('student_information',
>                 Field('name' ),
>                 Field('student_id')
>                 Field('married', 'boolean'),
>                 Field('spouse_name'))
> ####################################################################prompt
> for a student information###############################
>
> ef index():
>     """ a simple entry form with various types of objects """
>
>     form = FORM(TABLE(
>         TR('Your First:', INPUT(_type='text', _name='Fname',
>            requires=IS_NOT_EMPTY())),
>
>         TR('Your Middle Initial:', INPUT(_type='text', _name='Mname',
>            requires=IS_NOT_EMPTY())),
>
>         TR('Your Last Bane :', INPUT(_type='text', _name='Lname',
>            requires=IS_NOT_EMPTY())),
>
>         TR('Your student ID Number:', INPUT(_type='text', _name='Pid',
>            requires=IS_NOT_EMPTY())),
>
>         TR('Your email:', INPUT(_type='text', _name='e-mail',
>            requires=IS_EMAIL())),
>
>         TR('Your address:', INPUT(_type='text', _name='Paddress',
>            requires=IS_NOT_EMPTY())),
>
>         TR('Your Phone Number:', INPUT(_type='text', _name='Pphone',
>            requires=IS_NOT_EMPTY())),
>
>         TR('Are You  a New student', INPUT(_type='checkbox',
> _name='new_student')),
>
>         TR('', INPUT(_type='submit', _value='SUBMIT')),
>         ))
>     if form.accepts(request.vars, session):
>         response.flash = 'form accepted'
>         if new_student:
>           redirect(URL(r=request, f='new_student'))
>           db.student.insert(first_name = form.vars.Fname)
>           db.student.insert(last_name = form.vars.Lname)
>           db.student.insert(middle_initial = form.vars.Mname)
>           db.student.insert(student_phone = form.vars.Pphone)
>           db.student.insert(first_name = form.vars.Fname)
>           db.student.insert(student_address = form.vars.Paddress)
>           db.student.insert(first_name =form.vars.Fname)
>         elif redirect(URL(r=request, f='student'))
>
>     elif form.errors:
>         response.flash = 'form is invalid'
>     else:
>         response.flash = 'please fill the form'
>     return dict(form=form, vars=form.vars)
> ############################################inserting new information
> of a student######################################################
> def new_student():
>
>          form = crud.create(db.student,
>               next=URL(r=request,f='insurance_subscriber'))
>
>          return dict(form=form)
>
> def new_student_information():
>
>          thisstudent = db.student[request.args(0)]
>          if not thisstudent:
>              redirect(URL(r=request, f='index'))
>          db.student_information.student_id.default=thisstudent.id
>
>          form = crud.create(db.student_information)
>
>          return dict(form=form)
>
> #########################################accessing existing
> information###########################################################
> def student():
>     thisstudent = db((db.student.student_ID == form.vars.Pid)).select
> ()
>     #thisstudent = db.student[request.args(0)]
>     if not thisstudent:
>         redirect(URL(r=request, f='index'))
>
>     return dict( records=records)
>
> def student_information():
>
>          thisstudent = db.student[request.args(0)]
>          if not thisstudent:
>              redirect(URL(r=request, f='index'))
>          thisstudent_information = db
> (db.student_information.student_id == thisstudent.id).select()
>
>          return dict(thisstudent_information =
> thisstudent_information)
> ###########################################################################­#####################################
> ((=records}}  in student.html
> {{=thisstudent_informationa0 in student_information
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to