Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9086277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:26:57+00:00 2026-06-16T21:26:57+00:00

There are may button son php page. I want to submit value of button

  • 0

There are may button son php page. I want to submit value of button and the delete record from table using that value. Ajaxz code is

$('#product-table td #delete').live("click", function () {
                var doDelete = confirm('Are you sure you want to delete this record?');
                deleteLinkObj = $(this);

                if (doDelete) {


                    var id = $(this).attr('accesskey');
        $("#deleteid").val(id); 
        $.ajax({
                    url: "purchase.php",
                    data: {deleteid:id},
                    dataType: 'html',
                    success: function() {

                    }
                });


                }
                else { return false; }
                });

On PHP I am trying to use value of deleteid but its not coming
PHP code is

if(@$_POST['deleteid']!="")
                    {
                    $sql="delete from purchasedetails where purchaseid='".$_POST['deleteid']."'";
                    if(!mysql_query($sql))
                            {
                            die('Error: ' . mysql_error());
                            }
                            else
                            {
                            $msg="Data is deleted";
                            }
                    }   

I have tried usinng isset($_POST[‘deleteid’]) then also its showing error

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T21:26:58+00:00Added an answer on June 16, 2026 at 9:26 pm

    In your ajax call you aren’t setting the request method to POST, therefore it will default to GET, that is why your post var is never present:

        $.ajax({
                    type: 'POST',
                    url: "purchase.php",
                    data: {deleteid:id},
                    dataType: 'html',
                    success: function() {
    
                    }
                });
    

    As a quick fix for your SQL Injection vulnerability you can cast the id as int, but you should consider upgrading to PDO or MySQLi because the library you’re using is deprecated.

    $sql="delete from purchasedetails where purchaseid='".(int)$_POST['deleteid']."'";
    

    Storing your purchaseid as the elements accesskey is not the best place, it would be better as a data-myid attribute, so you can access it with $(this).data('myid').

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My ListViewItems have delete buttons in them. From those button's click events I want
May I know if there is any way to remove non-alphabetical symbols from a
Is there an easy way to recursively ZIP a directory that may or may
There is any ways to listing all main directories present in php server(may it
Is it possible to use JQuery & PHP to create a like button that
In a WinForm application that calls a third-party command line tool, there may be
I have a page with a dynamic table, data pulled from a GET method.
I like to place a feedback button on may main (MDIParent) form that simulates
Pretty new to Perl so there may be a very obvious solution here. I'm
I have the following String Sample however in some occurences there may be one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.