how to submit a form in wordpress

蹲街弑〆低调 提交于 2019-12-11 03:50:38

问题


I am using wordpress 3.3.1 with twentyten theme,

i have created a plugin to create a custom form,

i have successfully installed this in wordpress,

my plugin file code is as follows

<?php
function guest_event_form()
{ 

if(isset($_POST['submit']) and $_POST['action']=='new registration')
{

    global $wpdb;
    $wpdb->query("Insert Query...");
}
else
{
?>
<form method="POST" action="" name="guest_registration" enctype="multipart/form-data"> 
<input type="text" id="name" name="name" value="">
<input type="submit" name="submit" value="Register Me Now"/>
<input type="hidden" name="action" value="new registration" />
</form>
<?php
}
}
add_shortcode( 'guest_event_form', 'guest_event_form' );
?>

whenever i am submitting this form, i returns to same page with search results,

so i guess the problem whenever i submit this form, wordpress takes this submit action as a search action, and it starts search

how do i overcome this problem??


回答1:


The Problem is because of following form element's id

<input type="text" id="name" name="name" value="">

name is one of the wordpress internal variable



来源:https://stackoverflow.com/questions/8924440/how-to-submit-a-form-in-wordpress

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!