php - error with submitting a form in wordpress -


i've created plugin (simple form) , shortcode.php file:

<?php add_shortcode('contact_form','contact_form');  function contact_form(){     if (isset($_post['submit'])){         global $wpdb, $table_prefix;         $name = $_post['name'];         $data = array('name'=>$name,'message'=>'message');         $wpdb->insert($table_prefix.'contact_form',$data,array('%s','%s'));         echo 'added';     }      ?>     <form method="post" action="" id="contact_form">         name: <input type="text" name="name"><br>         <input type="submit" name="submit" value="submit">     </form> <?php } 

when submit form, if write sth in text field, says 'the page doesn't exist' if leave empty, submits form. problem? have used shortcode in page.

see this question on wordpress stackexchange site. in summary, wordpress gets confused field called name. try renaming (say) contact_name.

loads more detail here (also wpse).


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -