Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
317 views
in Technique[技术] by (71.8m points)

sql - delete button in PHP website behaving like static when clicked

i have a simple delete button in PHP which uses simple SQL query to delete the data from database, I have used the following code:

$myid = $this->uri->segment('3');
if (isset($_POST['submit'])){
    $ret = mysqli_query($con,"delete * from smart_category where name='$myid'");
    header("Location: https://cloudclassmate.com/jewelry-catalogue/admin/viewcategory");
}
<div style="margin-left:38%" class="clearfix">
    <a href="https://cloudclassmate.com/jewelry-catalogue/admin/viewcategory"> 
        <button type="button" class="cancelbtn bemine">Cancel</button></a>
    <form action="" method="post" ><button type="submit" name="submit"  class="deletebtn bemine">Delete</button></form>
</div>

the problem here is if I click the delete button, its not responding, nothing is happening. the button is like static. can anyone please tell me what could be wrong here

question from:https://stackoverflow.com/questions/66064196/delete-button-in-php-website-behaving-like-static-when-clicked

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If any Javasscript is not involved, than just put form action. Also send myid in the request or in URI. please see below:

<div style="margin-left:38%" class="clearfix">
    <a href="https://cloudclassmate.com/jewelry-catalogue/admin/viewcategory"><button type="button" class="cancelbtn bemine">Cancel</button></a>
    <form action="abc.php" method="post" ><button type="submit" name="submit"  class="deletebtn bemine">Delete</button></form>
</div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...