def register():
    if request.method == "POST":
        button = request.form['button']
        name = request.form["usern"]
        paswrd = request.form["userp"]  
        if button == "Register":
            if database.nameInSys(name) == 0:
                session["user"] = name
                user = session["user"]
                database.createNewUser(name,paswrd)
                return redirect(url_for("login"))
        if button == "Return To Login":
            return redirect(url_for("login"))
    return render_template("registerpage.html")
def creator2(prname):
    user = session['user']
    if request.method == "POST":
        button = request.form['button']
        if button == "Save":
            pname = prname
            user = session["user"]
            html =  request.form["pagehtml"]
            database.addProject(user,pname,html)
            return redirect(url_for("creator2",prname=prname))
        if button == "Return to Homepage":
            return redirect(url_for("home"))
        if button == "Publish to Public Projects":
            pname = prname
            user = session['user']
            html = request.form["pagehtml"]
            database.addPublicProject(user,pname,html)
        if button == "Find User":
            pname = prname
            use = session["user"]
            tar = request.form["colabname"]
            if database.nameInSys(tar) == 0:
                tar = "ERR0RZ"
                html = database.getProject(use,pname)
            else:
                html = database.getProject(use,pname)
                database.makeCollab(use,pname,tar)
                database.addProject(tar,pname,html)
                database.makeCollab(tar,pname,use)
            return render_template("creator.html",p=html,colab=[tar,pname])
        if button == str(database.whoCollab(session['user'],prname)):
            use = session["user"]
            pname = prname
            database.stopCollab(use,pname)
    project = database.getProject(user,prname)
    if database.isCollab(user,prname):
        return render_template("creator.html",p=project,colab=[database.whoCollab(user,prname),prname])
    return render_template("creator.html",p=project)