I am using python web.py framework to create a small web application which 
has just

1. Login screen (Authentication)

2. Screen with list of records(After succesfull login)

Presently i am trying to create a login screen authentication

I have created an `index.py` file with code as below

**index.py**

    import os
    import sys
    import web
    from web import form
    from web.contrib.auth import DBAuth
    
    render = web.template.render('templates/')
    
    urls = (
      '/',   'Login',
    )
    
    app = web.application(urls, globals())
    db = web.database(dbn='mysql', db='Python_Web', user='root', 
pw='redhat')
    
    class Login:
    
        login_form = form.Form( 
            form.Textbox('username', form.notnull),
            form.Password('password', form.notnull),
            form.Button('Login'),
            )
        
        def GET(self):
            form = self.login_form()
            return render.login(form)
    
        def POST(self):
    #        if not self.login_form.validates():
    #            return render.login(self.login_form)
            post = self.login_form()
            username = post['username'].value
            print username,">>>>>>>>>>>>>>>>>>>>>>username"
            password = post['password'].value
            ident = db.select('user', where='user_login=$username', 
vars=locals())
        
    if __name__ == "__main__":
        web.internalerror = web.debugerror
        app.run()     


My **login.html** code

    $def with (form)
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
    <html xmlns="http://www.w3.org/1999/xhtml"; lang="en" xml:lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Log in</title>
    </head>
    <body>
    <div id="container">
      <h1>Log in Details</h1>
      <form action="" method="post" accept-charset="utf-8">
        <p><label for="username">Username:
        <input type="text" name="username" id="username" maxlength="254" 
tabindex="1" />
        </label></p>
        <p><label for="password">Password:
        <input type="password" name="password" id="password" 
maxlength="254" tabindex="2" />
        </label></p>
        <p><label for="Login"></label><button id="Login" 
name="Login">Login</button></p>  
      </form>
    
    </div>
    </body>

When i run the above file with url `www.localhost:9080` in browser i can 
see the screen with fields `username, password and login` button , but when 
i enter username and password and  clicked `login` button and tried to 
print the username i cannot fetch any data from the browser and the result 
showing is as below

    None >>>>>>>>>>>>>>>>>>>>>>username
    0.0 (1): SELECT * FROM user WHERE user_login=NULL

Can anyone let me why i am unable fetch the details entered through browser 
?, am i missing anything in the above code and finally all my intention is  

to create a `login` page and `validate` the user details by checking in the 
database

and `redirect` to the next page if user exits

I request to please help me out in writing the code for fetching the 
details from the browser and checking in the database and redirecting to 
another html page if user exists. I am really stuck and breaking my heads 
to complete this process

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/webpy/-/1frf2gnYV-wJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/webpy?hl=en.

Reply via email to