php - When i click on any other button like desi food my order button is triggered

when ever i click any other button like desi food fast food or drink my order button is clicked automatically
i dont know either button have overlap each other or whats the problem i am a noob
<form method="post" action="orders.php" >
<div class="container">
<div class="container col-sm-8">
<h3 style="color:Purple; text-align: center; background:#A1F3B2; " > Menu: </h3>
<div class="container">
<div class="list-group">
<a href="#" class="list-group-item list-group-item-action"><button class="btn" data-toggle="collapse" data-target="#desi">Desi Food</button></a>
<div id="desi" class="collapse" style="background-color: white;" >
<input type="checkbox" value="haleem" name=check_list[] /> Haleem <br>
<input type="checkbox" value="chicken karahi" name=check_list[] /> Chicken Karahi <br>
<input type="checkbox" value="chanay paye" name=check_list[] /> Chanay Paye <br>
<input type="checkbox" value="sabzi" name=check_list[] /> Sabzi <br>
</div>
<a href="#" class="list-group-item list-group-item-action"><button class="btn" data-toggle="collapse" data-target="#fast">FAST FOOD:</button></a>
<div id="fast" class="collapse" style="background-color: white;">
<input type="checkbox" value="pizza" name=check_list[] /> Pizza<br>
<input type="checkbox" value="burger"name=check_list[] /> Burger<br>
<input type="checkbox" value="pizza cone"name=check_list[] /> Pizza Cone <br>
<input type="checkbox" value="Shawarma" name=check_list[]/> Shawarma <br>
</div>
<a href="#" class="list-group-item list-group-item-action"><button class="btn" data-toggle="collapse" data-target="#drink">DRINKS</button></a>
<div id="drink" class="collapse" style="background-color: white;" >
<input type="checkbox" value="coca cola" name=check_list[]/> Coca Cola<br>
<input type="checkbox" value="Red Bull" name=check_list[]/> Red Bull <br>
<input type="checkbox" value="Orange juice" name=check_list[] /> Orange Juice <br>
<input type="checkbox" value="Lemon Juice" name=check_list[]/> Lemon Juice <br>
</div>
</div>
<br>
<button type="submit" class="btn-success" style=" display: flex; margin:0 auto; align-items:center;">Order</button>
</div>
</form>
Answer
Solution:
Since the button in HTML5 has default behaviour likesubmit
(according to W3.org), you should usetype="button"
on your otherbutton
s.
Like this:
<button class="btn" data-toggle="collapse" data-target="#drink" type="button">DRINKS</button>
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: undefined array key php
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.