-1

When I tried to submit this HTML form, it didn't, then I tried it as a local file, and I got the same issue, can anyone help? Note: I am very new to flask, so forgive me if a made a beginner mistake.

Here's my code (login.html):

<from action="#" method="post">
    <input type="text" name="userName" placeholder="Enter Your Name..."/>
    <input type="password" name="passw" placeholder="Enter Your Password..."/>
    <input type="submit"/>
</from>

Here is my relevant Flask server code:

@app.route("/login/", methods=["POST", "GET"])
def login():
    return render_template("login.html")

#not doing anything with the password at the moment.
@app.route("/<user>")
def user(user):
    return f"<h1>{user}</h1>"
Fighter178
  • 303
  • 2
  • 9
  • 1
    Where do you expect it to submit to with `action="#"`? – Barmar Jan 26 '22 at 20:00
  • 2
    The whole point of using that is to prevent submission. – Barmar Jan 26 '22 at 20:01
  • 1
    [Form `action` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#attr-action). – Yevgeniy Kosmak Jan 26 '22 at 20:02
  • I handle the request on the same page, (I know it's insecure, but this is my first time making anything meaningful with flask), so I do not need to go to a different page, when submited, it post's the data to the server, (or at least I think so), and when I run .submit on is with JS, it says "Submit is not a function" if that helps. – Fighter178 Jan 26 '22 at 20:09

1 Answers1

0

looks like you are using a wrong tag. Your form is not being submitted because you have used tag. Try this

<form action="#" method="post">
  <input type="text" name="userName" placeholder="Enter Your Name..."/>
  <input type="password" name="passw" placeholder="Enter Your Password..."/>
  <input type="submit"/>
</form>

Also You can use submit button without form tag using java script.

joxing
  • 46
  • 5