Clear form after submit and page refresh - Wordpress -
I know the correct way to insert data is using AJAX, but I'm not concerned that the page refreshes Can a page clear the form data after refresh? Everything works well, the data is being presented in the table, and the page refreshes. But if I hit the refresh button again, it tells me that the data will be collected ... and I do not know what to do.
& lt ;? Php $ current_user = wp_get_current_user); If ($ current_user-> ID == 0) {} other {if (isset ($ _POST ['drop_artists'])) {$ answer = $ _POST ['drop_artists']; } And {$ answer = $ _POST ['artist_name']; } $ Date = current_time ('mysql'); $ Table = "t4t5_answers"; $ Sql = $ wpdb- & gt; Ready (enter $ current_user- & gt "$ table (user_id, post_id, info, answer, submit_date) value (% d,% d% s% s,% d)"; ID, $ post- & gt; Id, 'artist', $ answer, $ date); $ Wpdb- & gt; Query ($ SQL); Header ('location:'. Get_bloginfo ('url')); } // if (isset ($ _ POST ['form_sub']))? & Gt; & Lt; Form method = "post" action = "" id = "artist-look" & gt; & Lt; Ul & gt; & Lt; Li id = "Categories" & gt; & Lt ;? Php $ args = array ('show_option_all' = & gt; 'artist', 'hierarchical' => 1, 'child_of' => 406, 'order_by' = & gt; 'name', 'name' = & Gt; 'answer', 'hideable' => 0); Wp_dropdown_categories ($ args); ? & Gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; Input type = "text" name = "artist_name" value = "" size = "45" id = "input-title" /> & Lt; Input id = "submit button" class = "sub-type" type = "submit" name = "submit" value = "add" /> & Lt; / Form & gt;
After posting, redirects to send a user to a successful page Use This will actually post the page which does not appear in their history
if (($ _ POST)) {// do stuff header ("Location: $ _SERVER [ PHP_SELF] "); }
The URL must be a complete URL for the redirect, not a relative. Although in practice, I have not seen any problems with any browser relative URL.
Comments
Post a Comment