Reputation: 1
my html code:
<body class="u-body">
<section class="u-clearfix u-custom-color-3 u-section-1" id="sec-894d">
<div class="u-clearfix u-sheet u-sheet-1">
<h1 class="u-text u-text-default u-text-1">תענה על השאלות הבאות</h1>
<div class="u-form u-form-1">
<form action="#" method="POST" class="u-clearfix u-form-spacing-15 u-form-vertical u-inner-form" style="padding: 0px;" source="custom" name="form" action="/backtohome">
<div class="u-form-group u-form-name">
<label for="name-6797" class="u-form-control-hidden u-label"></label>
<input type="text" id="name-6797" name="name" class="u-border-6 u-border-custom-color-1 u-input u-input-rectangle u-radius-26 u-input-1" required="" placeholder="my question">
</div>
<div class="u-form-group u-form-group-2">
<label for="text-8918" class="u-form-control-hidden u-label"></label>
<input type="text" placeholder="my question" id="text-8918" name="image" class="u-border-6 u-border-custom-color-1 u-input u-input-rectangle u-radius-26 u-input-2" required="required">
</div>
<div class="u-form-group u-form-group-3">
<label for="text-da53" class="u-form-control-hidden u-label"></label>
<input type="text" placeholder="my question" id="text-da53" name="serverlink" class="u-border-6 u-border-custom-color-1 u-input u-input-rectangle u-radius-26 u-input-3" required="required">
</div>
<div class="u-form-group u-form-message">
<label for="message-6797" class="u-form-control-hidden u-label">Address</label>
<textarea placeholder="my question" rows="4" cols="50" id="message-6797" name="botinfo" class="u-border-6 u-border-custom-color-1 u-input u-input-rectangle u-radius-26 u-input-4" required=""></textarea>
</div>
<div class="u-form-group u-form-group-5">
<label for="text-d01b" class="u-form-control-hidden u-label"></label>
<input type="text" placeholder="my question" id="text-d01b" name="notes" class="u-border-6 u-border-custom-color-1 u-input u-input-rectangle u-radius-26 u-input-5">
</div>
<div class="u-align-center u-form-group u-form-submit">
<input type="submit" value="submit" class="u-btn u-btn-round u-btn-submit u-button-style u-radius-15">
</div>
</form>
</div>
</div>
</section>
my python code
@app.route("/disbuy", methods=["POST", "GET"])
async def disbuy():
try:
if request.method == "POST":
form_data = await request.form
notes = form_data["notes"]
if not notes:
# my code
return redirect(url_for("backtohome"))
else:
# my code
return redirect(url_for("backtohome"))
else:
return await render_template("disbuy.html")
except:
return redirect(url_for("loginerror"))
my error: it's not redirect to backtohome
Upvotes: 0
Views: 108
Reputation: 96
You have your action to action="/backtohome"
. Change that to action="/disbuy"
:
<body class="u-body">
<section class="u-clearfix u-custom-color-3 u-section-1" id="sec-894d">
<div class="u-clearfix u-sheet u-sheet-1">
<h1 class="u-text u-text-default u-text-1">תענה על השאלות הבאות</h1>
<div class="u-form u-form-1">
<form method="POST" class="u-clearfix u-form-spacing-15 u-form-vertical u-inner-form" style="padding: 0px;" source="custom" name="form" action="/disbuy">
<div class="u-form-group u-form-name">
<label for="name-6797" class="u-form-control-hidden u-label"></label>
<input type="text" id="name-6797" name="name" class="u-border-6 u-border-custom-color-1 u-input u-input-rectangle u-radius-26 u-input-1" required="" placeholder="my question">
</div>
<div class="u-form-group u-form-group-2">
<label for="text-8918" class="u-form-control-hidden u-label"></label>
<input type="text" placeholder="my question" id="text-8918" name="image" class="u-border-6 u-border-custom-color-1 u-input u-input-rectangle u-radius-26 u-input-2" required="required">
</div>
<div class="u-form-group u-form-group-3">
<label for="text-da53" class="u-form-control-hidden u-label"></label>
<input type="text" placeholder="my question" id="text-da53" name="serverlink" class="u-border-6 u-border-custom-color-1 u-input u-input-rectangle u-radius-26 u-input-3" required="required">
</div>
<div class="u-form-group u-form-message">
<label for="message-6797" class="u-form-control-hidden u-label">Address</label>
<textarea placeholder="my question" rows="4" cols="50" id="message-6797" name="botinfo" class="u-border-6 u-border-custom-color-1 u-input u-input-rectangle u-radius-26 u-input-4" required=""></textarea>
</div>
<div class="u-form-group u-form-group-5">
<label for="text-d01b" class="u-form-control-hidden u-label"></label>
<input type="text" placeholder="my question" id="text-d01b" name="notes" class="u-border-6 u-border-custom-color-1 u-input u-input-rectangle u-radius-26 u-input-5">
</div>
<div class="u-align-center u-form-group u-form-submit">
<input type="submit" value="submit" class="u-btn u-btn-round u-btn-submit u-button-style u-radius-15">
</div>
</form>
</div>
</div>
</section>
https://www.w3schools.com/html/html_forms.asp
Upvotes: 1