-1

I would like to send data using the form to the application. Unfortunately something is wrong. I'm still wondering if it's

name = request.form

is good because it doesn't even show me

print(name).

@app.route('/register', methods=['GET', 'POST'])
def register():
    form = RegisterForm(request.form)
    if request.method == 'POST' and form.validate():
        name = request.form("name")
        email = request.form("email")
        username = request.form("username")
        password = request.form("password")
        cur = mysql.connect.cursor()
        cur.execute("INSERT INTO users(name, email, username, password) VALUES(%s, %s, %s, %s)",
                    (name, email, username, password))
        cur.connection.commit()
        print(name)
        cur.close()
    return "true"

I tried to give

name = request.form.get("name")

but that doesn't work either

cluni
  • 1

1 Answers1

1

You have made a mistake with the syntax. the form is not callable so you cannot call it using form().

Try the following:

name = request.form["name"]

or

name = request.form.get("name", fallBackValue)

I hope this helps

Elie Saad
  • 516
  • 4
  • 8