default controller

def login():
    #login form
    login = auth.login(next="index")
    username = login.element('input', _name='username')
    username['_type']='text'
    username['_placeholder'] = 'Username (eg. saso)'
    username['_style']='height:50px; width:250px;'
    password = login.element('input', _name='password')
    password['_type']='password'
    password['_placeholder']='Password'
    password['_style']='height:50px; width:250px;'
    if login.errors:
        response.flash = 'form has errors'
        

    #register form    
    register = auth.register(next="verify")
    register['_class']="form-horizontal"
    register['_role']="form"
    full_name = register.element('input', _name='full_name')
    full_name['_type']='text'
    full_name['_placeholder']='Full Name (eg. Samuel Sowah)'
    full_name['_style']='height:30px; width:250px;'
    full_name['_class']='form-control'
    username = register.element('input', _name='username')
    username['_type']='text'
    username['_placeholder']='Username (eg. saso)'
    username['_style']='height:30px; width:250px;'
    username['_maxlength']='12'
    username['_class']='form-control'
    email = register.element('input', _name='email')
    email['_type']='email'
    email['_placeholder'] = 'Email (eg. [email protected])'
    email['_style']='height:30px; width:250px;'
    email['_class']='form-control'
    password = register.element('input', _name='password')
    password['_type']='password'
    password['_placeholder']='Password'
    password['_style']='height:30px; width:250px;'
    password['_class']='form-control'
    vpassword = register.element('input', _name='password_two')
    vpassword['_type']='password'
    vpassword['_placeholder']='Verify Password'
    vpassword['_style']='height:30px; width:250px;'
    vpassword['_class']='form-control'
    profile_picture = register.element('input', _name='profile_picture')
    countries = db().select(db.country.ALL)
    levels = db().select(db.level.ALL)
    if request.vars.country:
        schools = 
db(db.school.country_id==request.vars.country).select(db.school.ALL)
    else:
        schools = db(db.school.country_id==1).select(db.school.ALL)
    if request.vars.school_id:
        courses = 
db(db.course.school_id==request.vars.school_id).select(db.course.ALL)
    else:
        courses = db(db.course.school_id==1).select(db.course.ALL)
        
    if register.errors:
        response.flash = 'form has errors'
        errors=register.errors
    else:
        response.flash = 'please fill the form'
        errors=''
    return dict(login=login, register=register, countries=countries, 
schools=schools, courses=courses, levels=levels, errors=errors)




View  /login
{{=register.custom.begin}}
             <div class='tab-content'>
                        <div class="col-lg-4 tab-pane fade in active" 
id='personald'><br/>
                     <div class="form-group row">
                         <label for="auth_user_full_name" class="col-sm-4 
control-label">Full Name</label>
                         <div class="col-sm-6" id='full_name'>
                                    {{=register.custom.widget.full_name}}
                         </div>
                     </div>
                     <div class="form-group row" >
                     <label for="auth_user_username" class="col-sm-4 
control-label">Username</label>
                     <div class="col-sm-6">
                                    {{=register.custom.widget.username}}
                         </div>
                     </div>
                     <div class="form-group row">
                     <label for="auth_user_email" class="col-sm-4 
control-label">Email</label>
                     <div class="col-sm-6">
                                    {{=register.custom.widget.email}}
                         </div>
                     </div>
                     <div class="form-group row">
                     <label for="auth_user_password" class="col-sm-4 
control-label">Password</label>
                     <div class="col-sm-6">
                                    {{=register.custom.widget.password}}
                         </div>
                     </div>
                     <div class="form-group row">
                     <label for="verifypassword" class="col-sm-4 
control-label">Verify Password</label>
                     <div class="col-sm-6">
                                    {{=register.custom.widget.password_two}}
                         </div>
                     </div>
                            <p>Next step, enter your school details <a 
class='btn btn-default' href='#schoold' data-toggle="tab" 
onclick="jQuery('#school_pill').attr('class', 
'active');jQuery('#personal_pill').attr('class','');">Next →</a></p>
         </div><!-- /.col-lg-4 -->
         
                        <div class="col-lg-4 tab-pane fade" 
id='schoold'><br/>
           <div class="form-group">
                     <label for="auth_user_country" class="col-sm-4 
control-label">Country</label>
                     <div class="col-sm-6">
                     <span class='input-span'><select class='form-control' 
name='country' style='height:30px; width:250px;' class="generic-widget" 
id="auth_user_country"
     
onchange="jQuery('#auth_user_school').empty();jQuery('#auth_user_course').empty().html('<option>~~
 
Choose Your Course ~~</option>');
             ajax('school', ['country'], 'auth_user_school');">
                 <option value=''>~~ Choose Your Country ~~</option>
         {{for country in countries:}}
             <option value="{{=country.id}}"
                 {{=" selected='selected'"  if 
str(country.id)==request.vars.country else ""}}>
             {{=country.name}}</option>
         {{pass}}
                                 </select></span><br/>
                         </div>
                     </div>
                    
                      <div class="form-group">
                     <label for="auth_user_school" class="col-sm-4 
control-label">School</label>
                     <div class="col-sm-6">
                     <span class='input-span'><select class='form-control' 
name='school' style='height:30px; width:250px;' class="generic-widget" 
id="auth_user_school"
         onchange="jQuery('#auth_user_course').empty();
             ajax('course', ['school'], 'auth_user_course');" 
required='required'>
             <option value=''>~~ Choose Your School ~~</option>
         {{for school in schools:}}
             <option value="{{=school.id}}"
                 {{=XML(" selected='selected'") if 
str(school.id)==request.vars.school else ""}}>
             {{=school.name}}</option>
         {{pass}}
                                 </select></span><br/>
                         </div>
                     </div>
                    
                     <div class="form-group">
                     <label for="auth_user_course" class="col-sm-4 
control-label">Major</label>
                     <div class="col-sm-6">
                     <span class='input-span'><select class='form-control' 
name='course' style='height:30px; width:250px;' class="generic-widget" 
id="auth_user_course" 
         onchange="jQuery('#auth_user_level').empty();
             ajax('level', ['course'], 'auth_user_level');">
         <option value=''>~~ Choose Your Course ~~</option>
         {{for course in courses:}}            
             <option value="{{=course.id}}" 
                 {{=XML(" selected='selected'") if 
str(course.id)==request.vars.course else ""}}>
             {{=course.name}}</option>
         {{pass}}
                             </select></span><br/>
                         </div>
                     </div>
                    
                     <div class="form-group">
                     <label for="auth_user_level" class="col-sm-4 
control-label">Level</label>
                     <div class="col-sm-6">
                     <span class='input-span'><select class='form-control' 
name='level' style='height:30px; width:250px;' class="generic-widget" 
id="auth_user_level" >
         <option value=''>~~ Choose Your Level ~~</option>
         {{for level in levels:}}            
             <option value="{{=level.id}}"
             {{=" selected='selected'"  if 
str(level.id)==request.vars.level else ""}}>
             {{=level.name}}</option>
         {{pass}}
                                 </select></span>
                         </div>
                     </div>
                            
                            <div class="form-group">
                     <label for="auth_user_password" class="col-sm-4 
control-label">Please verify that you're not a bot</label>
                     <div class="col-sm-6">
                                    <div id="recaptcha">
                                        <script><!--
var RecaptchaOptions = {};
//--></script><script 
src="http://www.google.com/recaptcha/api/challenge?k=6LfGWO0SAAAAALiD4gZ44IR2kroUsh-1969UPf9h";
 
type="text/javascript">
</script>
                                     <noscript>
                                     <iframe frameborder="0" height="300" 
src="http://www.google.com/recaptcha/api/noscript?k=6LfGWO0SAAAAALiD4gZ44IR2kroUsh-1969UPf9h";
 
width="500">
                                     </iframe><br/>
                                     <input name="recaptcha_response_field" 
type="hidden" value="manual_challenge" />
                                     </noscript>
                                    </div>
                         </div>
                     </div>
                     
                 <div class="form-group">
                     <div class="pull-right">
                                    Finish! <button type='submit' 
style='margin-right:30px;' class="btn btn-success" href="#" 
role="button">Sign Up</button>
                         </div>
                     </div>
                 </div>
         </div>
                    {{=register.custom.end}}

Whenever I submit this form, it keeps redirecting me to the same login 
page... what am i doing wrong?

On Saturday, 15 February 2014 17:06:15 UTC, sasogeek wrote:
>
> I wrote a custom register form that works on my local machine during 
> development, I deployed it to pythonanywhere and now the register form 
> isn't working... what could be the problem? idk what to do exactly
>
> register = auth.register(next="verify")
> locally, register takes me to /verify if there are no errors.
> on pythonanywhere, it reloads /login
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to