In the custom table, I try to update a specific column with using $wpdb->update class and using HTML form for updating one column that has same id (in here dlname Is ID of data ).

The problem is this When I trying to update the column in my table using HTML form The page only will Refresh

BUT When I manually set ID in codes and THEN typing and submitting new value by HTML form it will work like charm.

It seems to be machine cannot understand the value that inputted from the form This is my code :

    global $wpdb;

    $data_array = array(

    'dstatus' => $_POST['dstatuschange'],
    'downloadname' => $_POST['dlname'],


    $data_where = array('downloadname' =>'dlname');

And this is my Form :

<form method="POST">

    <label> Input One : </label>
    <input type="text" name="dlname"/>

    <label> Input Two : </label>
    <input type="text" name="dstatuschange" />

    <button type="submit" name="btnUpdate"> Submit </button>

1 Answer 1


First, an observation: the line highlighted below is correct as per your logic? This query will set the dstatus and downloadname fields in a row as $_POST['dstatuschange'] and $_POST['dlname'] if downloadname field is the 'dlname' string. Maybe you wanted to put the $_POST['dlname'] variable in your WHERE condition?

Second, wordpress custom POSTs work much better if you use the standard wordpress way to manage them. Look at this answer to see how to handle properly a custom form submission.

  • The line i highlighted is my logic . Yeah i wanna update the row WHERE My downloadname is equal with inputted value from the html form in dlname . And about custom post you offered me : unfortunately we can't change our plugin base in this time and the point where we stand now. Is there possible to figured it out with this code ?
    – TheXrion
    Feb 23, 2019 at 18:52
  • Thank you @Fabrizio There is need to put $_POST['dlname'] in $data_where as you pointed to and it will work fine. and this link Have the Same Solution.
    – TheXrion
    Feb 23, 2019 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.