如何在wordpress中提交表单 [英] how to submit a form in wordpress

查看:191
本文介绍了如何在wordpress中提交表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是带有 twentyten 主题的 wordpress 3.3.1,

I am using wordpress 3.3.1 with twentyten theme,

我创建了一个插件来创建自定义表单,

i have created a plugin to create a custom form,

我已经在 wordpress 中成功安装了这个,

i have successfully installed this in wordpress,

我的插件文件代码如下

<?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,

所以我猜每当我提交此表单时都会出现问题,wordpress 将此提交操作作为搜索操作,并开始搜索

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??

推荐答案

问题是由于以下表单元素的 id

The Problem is because of following form element's id

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

name 是 wordpress 内部变量之一

name is one of the wordpress internal variable

改成这样:

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

这篇关于如何在wordpress中提交表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆