Flask/html/Jinja POST/GET requests - html

Would anyone know why the below Python flask form is not triggering a POST/GET request.
The below code has been compiled in a html file.
<form action="/admin/dashboard" method="GET">
<div class="form-group">
<label>id</label>
<input class="form-control" type='text' name='username'>
</div>
<div class="form-group">
<label>year</label>
<input class="form-control" type='text' name='username'>
</div>
<div class="form-group">
<label>yes/no</label>
<input class="form-control" type='text' name='username'>
</div>
<hr>
<button type="button" class="btn btn-primary btn-sm">search catalouge</button>
<hr>
<p1>not in list add data below</p1>
</form>

Related

How to add a button on the right o bootstrap panel

I am trying to add a delete button on the right of bootstrap panel. No matter what I do it is not getting inline with panel heading. Help please.
<div class="panel-heading">
Update Article
<form class="delete_form pull-right" id="delete_form" method="post" action="" enctype="multipart/form-data">
<input type="submit" name="submit" class="btn btn-danger" value="Delete" onclick="return confirm(\'Are you sure you want to delete this item?\');" />
</form>
</div>
Edit 1: Added rest of the panel code.
<div class="panel-body">
<form class="article_form" id="article_form" enctype="multipart/form-data">
<div class="row">
<div class="col-sm-6 form-group">
<label for="title" requiredField>Title*</label>
<input type="text" class="form-control" id="title" value="$title" name="title" maxlength="100" required>
</div>
<div class="col-sm-6 form-group">
<label for="pdf_link">PDF Link*</label>
<input type="text" class="form-control" id="pdf_link" value="$pdfurl" name="pdf_link" maxlength="100" required>
</div>
</div>
<div class="row">
<div class="word_file col-sm-6 form-group">
<label>Upload Microsoft Word file of the article.</label>
<input class="form-control" accept=".doc, .docx" type="file" id="word_file" name="word_file">
</div>
<div class="word_unavailable col-sm-6 form-group">
<label for="ur_name">Check if Microsoft Word file is unavailable.</label>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="chk_word" name="chk_word">
<label class="form-check-label" for="wordfiles">MS Word file is unavilable</label>
</div>
</div>
</div>
<input type="submit" name="submit" class="btn btn-primary" value="Update" />
</form>
</div>
</div>
I am not using any custom css.
Edit 2: Needed results
<body>
<div class="panel panel-default">
<div class="panel-heading container-fluid">Update Article
<form class="pull-right" id="delete_form" method="post" action="" enctype="multipart/form-data">
<input type="submit" name="submit" class="btn btn-danger" value="Delete" onclick="return confirm(\'Are you sure you want to delete this item?\');" />
</form>
</div>
<div class="panel-body">Any content</div>
</div>
</body>

Form not submitting POST

I have this form in my Spring Boot/Thymeleaf/Bootstrap application:
<form action="/person" method="POST">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" id="name">
</div>
<button type="submit" class="btn btn-primary">Create</button></form>
Now the issue is that when I submit the form it just makes a GET request to "/?" url instead of POSTing to "/person".
What could be the reason for that behavior?
<form action="/person" method="post">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" id="name">
</div>
<input type="submit" class="form-submit">
</form>

How to Edit any posted text in react

I can see the title to be edited but the question is how can I view a detailed bar for editing? in the tutorials, I am following works correctly but with me, it doesn't.
'{{#each errors }}
<div class="alert alert-danger">{{text}}</div>
{{else}}
{{/each}}
<div class="card card-body">
<h3>Edit Candidates</h3>
<form action="/ideas" method="post">
<div class="form-group">
<label for="title">Title</label>
<input type="text" class="form-control" name="title" value="{{idea.title}}" required>
</div>
<div class="form-group">
<label for="details">Details</label>
<textarea class="form-control" name="details" required {{idea.details}}></textarea>
</div>
<button type="submit" class="btn btn-primary">submit</button>
</form>
</div>'

form not submitting on localhost or remote

After submitting the form nothing happens, page doesn't reloads. Out of ideas.
<form action="/departmentinsert.php" method="POST" class="contact-form">
<div class="col-md-12">
<div class="row">
<div class="form-group">
<input class="form-control" id="name" name="name" placeholder="Отделение" type="text">
</div>
</div>
</div>
<div class="col-md-12">
<div class="row">
<button type="submit" name="submit" id="submit">
Добавить <i class="fa fa-paper-plane"></i>
</button>
</div>
</div>
</div>
</form>
to submit the form you will need to use <input type="submit"> instead of the <button> tag
once you update the code I am sure it will work, if you are using PHP it should be like this
<?php
if(isset($_POST['submit']){
// your code
}
?>
if this doesn't work please post your PHP as well so i can check where's the problem
hope this help.
I changed formatting to and it works now. My code now is
<form action="" method="POST" >
<div class="form-group">
<input class="form-group" id="name" name="name" placeholder="Отделение" type="text">
</div>
<div class="form-group">
<input class="form-group" id="title" name="title" placeholder="Заголовок" type="text" size="255">
</div>
<div class="form-group">
<input class="form-group" id="breadcrumb" name="breadcrumb" placeholder="Хлебные крошки" type="text" size="255">
</div>
<div class="form-group">
<input class="form-group" id="pagetitle" name="pagetitle" placeholder="Титул страницы" type="text" size="255">
</div>
<div class="form-group">
Опубликовать?
<input name="active" type="checkbox" value="1" checked>
</div>
<div class="form-group">
<button type="submit" name="submit" id="submit">
Добавить <i class="fa fa-paper-plane"></i>
</button>
</div>
</form>

HTML Form Post handling

I have a form as detailed below. It uses a post method to send data to getUsername.php. This file echoes some JSON results from mysql db.
Am wondering how do I grab this data? When I hit submit it navigates to the file and displays the JSON. I want to grab the JSON and stay on the same page or move to a different one!
I have kept the php file simple because the data is also used for returning data to my android app.
<div class="well bs-component">
<form id ='formLogin' action="http://localhost/getUsername.php" method="post" class="form-horizontal">
<fieldset>
<legend>Sign In</legend>
<div class="form-group">
<label for="inputEmail" class="col-lg-2 control-label">Email</label>
<div class="col-lg-10">
<input name='email' type="text" class="form-control" id="inputEmail" placeholder="Email">
</div>
</div>
<div class="form-group">
<label for="inputPassword" class="col-lg-2 control-label">Password</label>
<div class="col-lg-10">
<input name='password' type="password" class="form-control" id="inputPassword" placeholder="Password">
<div class="checkbox">
<label>
<input type="checkbox"> Checkbox
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-lg-offset-2">
<button type="reset" class="btn btn-default">Cancel</button>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</fieldset>
</form>
I believe this cannot be done from a form. I instead used jquery post function to return data