• Hi All,

    I have written a little piece of code that will insert a word into a wp custom db table after submit in wp admin panel.

    Now when i hit F5, it will insert the data a second time. How can i solve this

    if (!empty($_POST['add_bcw']) && ($_POST['add'] == 'add_word')) {
    
    $insert_data = "INSERT INTO " . wp_badcommentswords . " (bcw_name) " .
    	  "VALUES ('" . $_POST['add_bcw'] . "')";
    $results = $wpdb->query($insert_data);
    }

    How do i solve this ?

Viewing 1 replies (of 1 total)
  • Thread Starter no_ob

    (@no_ob)

    I’ve created the table as
    bcw_name varchar(255) NOT NULL UNIQUE,

    Is this a valid way to keep double entry’s out of here ? It works, but is it a valid way ?

Viewing 1 replies (of 1 total)
  • The topic ‘insert into table and refresh issue’ is closed to new replies.