title: NameError: global name 'form' is not defined. Flask-MySQL
body: <p>i'm new in Python and Flask. I try to create a website where you can add books and write them into a MySQL-database. When I run my Project with PyCharm it works fine until I navigate to the site where I would like to add my books. 
  <strong>The Error says: NameError: global name 'form' is not defined.</strong>
  Can someone please help me to fix this? Maybe I write the code at the wrong place, I dont know.</p>
  
  <p>My Code is:</p>
  
  <p><strong>views.py:</strong></p>
  
  <pre><code>from flask import render_template, flash, redirect, session, url_for, request
  from flask.ext.login import login_user, logout_user, current_user, login_required
  from app import app, db, mysql
  from .forms import LoginForm, AddForm, RegForm
  from .models import User
  
  @app.route('/books/add/admin', methods=['GET', 'POST'])
  def books_add_admin():
      add = AddForm()
  
      if request.method == 'POST':
          cursor = mysql.connect().cursor()
               '''
               cursor = mysql.get_db().cursor()
               author = request.args.get(form.author.data)
               '''
          test = request.args.get(form.title.data)
          author = request.args.get(form.author.data)
          verlag = request.args.get(form.publisher.data)
          isbn = request.args.get(form.isbn.data)
          auflage = request.args.get(form.edition.data)
          exemplare = request.args.get(form.copies.data)
          kurztext = request.args.get(form.short_text.data)
          cursor.execute("INSERT INTO books (Titel, Autor, Verlag, ISBN, Auflage, Info)
          VALUES (titel, author, verlag, isbn, auflage, info);")
  
               #cursor = mysql.connect().cursor()
          con.commit()
          curser.close()
  </code></pre>
  
  <p><strong>And the code of the forms.py:</strong></p>
  
  <pre><code>from flask.ext.wtf import Form
  from wtforms import StringField, IntegerField, BooleanField, PasswordField, validators,
  TextAreaField
  from wtforms.validators import DataRequired, Length
  
  
  class LoginForm(Form):
      student_number = IntegerField('student_number', validators=[DataRequired()])
      password = PasswordField('password', validators=[DataRequired()])
      #remember_me = BooleanField('remember_me', default=False)
  
  class AddForm(Form):
      title = StringField('title', validators=[DataRequired()])
      author = StringField('author', validators=[DataRequired()])
      publisher = StringField('publisher', validators=[DataRequired()])
      isbn = IntegerField('isbn', validators=[Length(min=10, max=13)])
      edition = IntegerField('edition', validators=[Length(min=1, max=3)])
      copies = IntegerField('copies', validators=[Length(min=1, max=3)])
      short_info = TextAreaField('short_info', validators=[Length(min=0, max=1040)])
  
  class RegForm(Form):
      student_number = IntegerField('student_number', validators=[Length(min=6, max=7)])
      forname = StringField('forname', validators=[DataRequired()])
      surname = StringField('surname', validators=[DataRequired()])
      email = StringField('email', validators=[DataRequired()])
      password = PasswordField('password', validators=[Length(min=6, max=24)])
      password2 = PasswordField('password2', validators=[Length(min=6, max=24)])
  </code></pre>