title: Flask - Registration for new user doesn't work - Bad request
body: <p>I am doing some app with Flask and I am working on registration now. I am working with SQL and not SQLAlchemy on this case (just to work with SQL a bit more)
  Also using Flask-WTF for forms.</p>
  
  <p>I successfully create database table:</p>
  
  <pre><code>class RegisterForm(Form):
      name = StringField(
      'Username',
      validators=[DataRequired(), Length(min=4, max=25)]
      )
      email = StringField(
      'Email',
      validators=[DataRequired(), Length(min=6, max=40)]
      )
      password = PasswordField(
      'Password',
      validators=[DataRequired(), Length(min=6, max=40)])
      confirm = PasswordField(
      'Repeat Password',
      validators=[DataRequired(), EqualTo('password', message='Passwords must match')]
      )
  </code></pre>
  
  <p>In my views.py I have next for registration:</p>
  
  <pre><code>@app.route("/register/", methods=["GET", "POST"])
  def register():
      form = RegisterForm(request.form)
  
      if request.method == "POST" and form.validate_on_submit():
  
          name = request.form["name"]
          email = request.form["email"]
          password = request.form["password"]
  
          g.db.connect_db()
          g.db.execute("INSERT INTO users(name, email, password) VALUES (?,?,?)", (name, email, password))
          g.db.commit()
          g.db.close()
      return render_template("register.html", form=form)
  </code></pre>
  
  <p>And my simple form:</p>
  
  <pre><code>&lt;form action="/" method="post"&gt;
              {{ form.csrf_token }}
                &lt;div class="form-group"&gt;
                  &lt;label for="usernameInput"&gt;Username&lt;/label&gt;
                  &lt;input type="text" name="name" class="form-control" id="usernameInput"&gt;
                &lt;/div&gt;
                &lt;div class="form-group"&gt;
                  &lt;label for="emailInput"&gt;Email&lt;/label&gt;
                  &lt;input type="email" name="email" class="form-control" id="emailInput"&gt;
                &lt;/div&gt;
                &lt;div class="form-group"&gt;
                  &lt;label for="passwordInput"&gt;Password&lt;/label&gt;
                  &lt;input type="password" name="password" class="form-control" id="passwordInput"&gt;
                &lt;/div&gt;
                &lt;div class="form-group"&gt;
                  &lt;label for="confirmInput"&gt;Confirm password&lt;/label&gt;
                  &lt;input type="password" name="confirm" class="form-control" id="confirmInput"&gt;
                &lt;/div&gt;
                &lt;button type="submit" class="btn btn-default btn-block"&gt;Register&lt;/button&gt;
                {% if error %}
                  &lt;p class="error"&gt;&lt;strong&gt;Error:&lt;/strong&gt; {{error}} &lt;/p&gt;
                {% endif %}
              &lt;/form&gt;
  </code></pre>
  
  <p>Now I have been trying, changing and fixing for 2 days and can't find a problem. When I enter all the data and click Register I get 400 Bad request.
  Perhaps it something silly and I just can't see it.</p>
  
  <p>If anyone can help, I would appriciate.
  If need more info or code, let me know.</p>
  
  <p>Thanks</p>