Skip to content
Advertisement

Delete button with alert does not work in php

If I click the delete button, then it is asking permission from me to delete the contents but after clicking, OK contents are not deleting.

In my understanding, my code can not catch the id to delete the contents.

In my browser search box it is showing :

localhost/new/tree1/view_tree.php?id=

For getting the id code is given below:

JavaScript

For deleting the row (contents) code is given below:

JavaScript

Advertisement

Answer

You’re not echoing your variable here.

JavaScript

Add an echo

JavaScript

Or use short echo tag

JavaScript

Also, your delete query is wrong. You’re missing FROM.

Should be this:

JavaScript

Also try reading up on SQL Injections, How can I prevent SQL injection in PHP?

Your current code is vulnerable.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement