-1

I am working on a web GUI for a program I wrote the first thing a user of this software will access is the default login page for the program with that, said how do you take the username and password that the user-provided and validate it

how do you take the input from the user?

this is the login page in the flask script


@app.route('/login', methods=['GET', 'POST'])
def login():
    if request.method == 'POST':
        if  request.form['log'] == "Log In Here":


            u_name = request.form['Uname']
            pass_wrd = request.form['Pass']
        else:
            pass
        print ( u_name , pass_wrd)
        return 
    else:
        return render_template('login-form.html')

this is the HTML side for the login page

<form id="login" method="get" action="login.php">    
        <label><b>User Name     
        </b>    
        </label>    
        <input type="text" name="Uname" id="Uname" placeholder="Username">    
        <br><br>    
        <label><b>Password     
        </b>    
        </label>    
        <input type="Password" name="Pass" id="Pass" placeholder="Password">    
        <br><br>    
        <input type="button" name="log" id="log" value="Log In Here">       
        <br><br>    
        <input type="checkbox" id="check">    
davidism
  • 121,510
  • 29
  • 395
  • 339
Sec Team
  • 47
  • 8

1 Answers1

1

if request.form["log"] == "Log In Here

You have literally used the method here ^

request.form['name'] will get values from the input tag with name = 'name' (you can change that to catch the input values you want)

Store the value in variable and authorize the user with username and password from your database.

  • when i press the log in button nothing happens – Sec Team Sep 15 '20 at 16:13
  • So, you either change the type of your input to "submit" or add an **on_click** attribute to your button. If I were to suggest, changing your button input type will do the job quickly. Remember, the action of the submit button will be executed as defined in the action attribute of the form tag. – Devesh Datwani Sep 16 '20 at 08:54