Issue
I am a beginner to flask. I am making a program to store records of clinic patients. For this, I have made 2 pages, one to show and receive records of patients (which I would be referring to home page), and another to edit the patient's records (which I would be referring to edit page). So in both pages, there is a form.
But the trouble that I am facing for a long time is that the form submitted on the edit page executes the POST request code of my home page rather than executing the POST request code of the edit page.
Here is some of the POST request code of my home page:
@app.route("/", methods=["POST", "GET"])
def index():
if request.method == "POST":
patient_number=request.form["PNo"]
patient_name=request.form["PName"]
patient_mobile_number=request.form["Mob"]
patient_location=request.form["Loc"]
patient_arrival_date=request.form["ArrivDate"]
patient_recorded_by=request.form["By"]
And here is the POST request code for my edit page:
@app.route("/edit/<int:sno>", methods=["POST", "GET"])
def editing(sno):
if request.method == "POST":
patient_number = request.form["PNo"]
patient_name = request.form["PName"]
patient_mobile_number = request.form["MNo"]
patient_location = request.form["Location"]
patient_arrival_date = request.form["DOA"]
patient_recorded_by = request.form["CreatedBy"]
Both of the above-mentioned code resides on the same python file, and on submitting the form from the edit page shows this error
As there is no input element named Mob
in my edit page's form (but there is an input element named Mob
in my home page's form), hence this error shows that python rather than executing the POST request code of my edit page, executes POST request code of my home page.
Can anybody please tell me where am I going wrong and how can I correct it.
Thanks in advance
Solution
I got this problem solved by myself. Thanks everyone who spent their time trying to help me out. Actually I wrote <form action="/">
on my edit page's form due to which all this happened. Sorry for the trouble.
Answered By - Sam Varghese
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.