The code for register is as follows

@app.route("/register", methods=["GET","POST"]) def register():

if  not request.method=="POST":

    if request.form.get("username",False)  or request.form.get("password",False) or request.form.get("password2",False):
        return apology("Must enter username and password")
    elif request.form.get("password")!=request.form.get("password2"):
        return apology("Entered passwords must match!!")
        row=db.execute("SELECT username from users where username=:user",user=request.form.get('username'))
        if not row ==None and not len(row)==1:
                db.execute("INSERT INTO users(username,hash) values(:user,:concealed)",user=request.form.get("username"),concealed=encrypted)
            except RuntimeError:
                return render_template("register.html")
            return redirect(url_for("index"))
            return apology("User already exists")
    return apology("something is wrong")

WHile trying to run the code i see the following error

 RuntimeError: Bind parameter 'user' without a renderable value not allowed here.

I have tried fixes such as changing the name of the parameter in the html file and changing the name of the binding parameter nothing seems work.Infact i have checked for the None case so i see no reason as to why this should occur. Help that would aid in fixing this would be appreciated.

  • You mean if request.method=="POST": without not, right?
    – Blauelf
    May 15 '17 at 11:00

I believe you don't want the not in the first if.

If you requested the page via GET, return the registration form.

If you requested the page via POST, supplying form parameters, check the parameters and if reasonable perform a registration.

You might want to read about dict's get method first, you seem to assume a different behaviour.

The error is probably caused by request.form.get('username') being None. You should not reach this line if that's the case, so your previous ifs are probably wrong.

  • i removed the not in the modified code to check if it works it never goes into that part of the condition.In the html file for register ,the form method is post ,so i dont seem to understand where it could have gone wrong @Blauelf May 16 '17 at 14:03
  • If you click a "register" link to get the form, that's HTTP GET, while you should submit the form using HTTP POST, both under the same route. Have you also fixed your other conditions, especially have you read about dict's get method (not related to HTTP GET)?
    – Blauelf
    May 16 '17 at 14:16
  • This helped a lot ,turns out I had to deal with the get and the post request separately because both had their requests submitted to the same code . May 19 '17 at 19:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .