def register(request): state = formIsValid(request.POST) emailState = emailExists(request.POST) usernameState = usernameExists(request.POST) if emailState['exists']: errors = emailState['errors'] context = {'errors': errors} return render(request, "reviewApp/index.html", context) elif usernameState['exists']: errors = usernameState['errors'] context = {'errors': errors} return render(request, "reviewApp/index.html", context) else: if state['isValid']: user = User.objects.create(name=request.POST['name'], username=request.POST['username'], email=request.POST['email'], password=request.POST['password']) request.session['user'] = request.POST['email'] return redirect("/books") else: errors = state['errors'] context = {'errors': errors} return render(request, "reviewApp/index.html", context) return render(request, 'reviewApp/books.html')
def show_info(): state = formIsValid(request.form) print state if (state['isValid']): print "success" return redirect('/success') else: print "error" for error in state['errors']: flash(error) return redirect('/')
def register(request): state = formIsValid(request.POST) if state['isValid']: user = User.objects.create(first_name=request.POST['first_name'], last_name=request.POST['last_name'], email=request.POST['email'], password=request.POST['password']) request.session['user'] = request.POST['email'] return redirect("/secrets") else: errors = state['errors'] context = {'errors': errors} return render(request, "secretsApp/index.html", context)
def register(request): state = formIsValid(request.POST) if state['isValid']: user = User.objects.create(first_name=request.POST['first_name'], last_name=request.POST['last_name'], email=request.POST['email'], password=request.POST['pw']) context = {'user': user} print 'registered!' return render(request, "loginRegApp/success.html", context) else: errors = state['errors'] context = {'errors': errors} return render(request, "loginRegApp/index.html", context)
def submit(request): state = formIsValid(request.POST['username']) if (state['isValid']==True): User.objects.create(username=request.POST['username']) users = User.objects.all() context={ "users":users } return render(request, 'validationApp/success.html', context) else: context={ "error":"Username is not valid!" } return render(request, 'validationApp/index.html', context)
def create(): state = formIsValid(request.form) if (state['isValid']): query = "INSERT INTO friends (first_name, last_name, email, created_at, updated_at) VALUES (:first_name, :last_name, :email, NOW(), NOW())" data = { 'first_name': request.form['first_name'], 'last_name': request.form['last_name'], 'email': request.form['email'] } mysql.query_db(query, data) return redirect('/') else: print "error" for error in state['errors']: flash(error) return redirect('/')
def create(): state = formIsValid(request.form) if (state['isValid']): query = "INSERT INTO emails (email, created_at, updated_at) VALUES (:email, NOW(), NOW())" # We'll then create a dictionary of data from the POST data received. data = {'email': request.form['email']} # Run query, with dictionary values injected into the query. mysql.query_db(query, data) flash('The email address you entered ' + request.form['email'] + 'is a VALID email address! Thank yoU!') return redirect('/success.html') else: print "error" for error in state['errors']: flash(error) return redirect('/')
def register(): state = formIsValid(request.form) if (state['isValid']): password = bcrypt.generate_password_hash(request.form['password']) query = "INSERT INTO users (first_name, last_name, email, password, created_at, updated_at) VALUES (:first_name, :last_name, :email, :password, NOW(), NOW())" data = { 'first_name': request.form['first_name'], 'last_name': request.form['last_name'], 'email': request.form['email'], 'password': password } result = mysql.query_db(query, data) query2 = "SELECT * FROM users WHERE id = :id" data2 = {'id': result} user = mysql.query_db(query2, data2) session['id'] = user[0] return render_template('/wall.html', user=user[0]) else: for error in state['errors']: flash(error) return redirect('/')