title: Flask Python submit button
body: <p>I am trying to create a page to register users but the submit button in my bootstrap form isn't working. When I hit the submit button, I get a bad request error. Here is the code in my python file:</p>
  
  <pre><code>@app.route('/register', methods=['GET', 'POST'])
  def register():
      if request.method == 'POST':
          if not request.form['username']:
              error = 'You have to enter a username'
          elif not request.form['email'] or '@' not in request.form['email']:
              error = 'You have to enter a valid email address'
          elif not request.form['password']:
              error = 'You have to enter a password'
          elif get_user_id(request.form['username']) is not None:
              error = 'The username is already taken'
          else:
              print(request.form['username'])
              db = get_db()
              db.execute('INSERT INTO user (username, email, pw_hash) VALUES (?, ?, ?)',
                         [request.form['username'], request.form['email'],
                          generate_password_hash(request.form['password'])])
              db.commit()
              flash('You were successfully registered and can login now')
              return render_template('control.html')
      return render_template('register.html')
  </code></pre>
  
  <p>also i have a html file register.html:</p>
  
  <pre><code>{% extends 'layout.html' %}
  {% block title %}Sign-up{% endblock title %}
  {% block body %}
  &lt;div class="container"&gt;
      &lt;form class="form-register" role="form" method="post" action="{{ url_for('register') }}"&gt;
          &lt;h2 class="form-register-heading"&gt;Please sign up&lt;/h2&gt;
          &lt;label for="username" class="sr-only"&gt;Username&lt;/label&gt;
          &lt;input type="username" id="inputUsername" class="form-control" value="{{ request.form.username }}" placeholder="Username" required autofocus&gt;
          &lt;label for="email" class="sr-only"&gt;Email address&lt;/label&gt;
          &lt;input type="email" id="inputEmail" class="form-control" value="{{ request.form.email }}" placeholder="Email address" required autofocus&gt;
          &lt;label for="password" class="sr-only"&gt;Password&lt;/label&gt;
          &lt;input type="password" id="inputPassword" class="form-control" placeholder="Password" required &gt;
          &lt;button class="btn btn-lg btn-primary btn-block" type="submit"&gt;Sign up&lt;/button&gt;
      &lt;/form&gt;
  
  &lt;/div&gt;
  {% endblock body %}
  </code></pre>
  
  <p>I can't find where I did it wrong, I'm new to python and flask!</p>