首页 \ 问答 \ WordPress中的自定义表单并将值存储到自定义数据库中(Custom form in WordPress and store values into custom database)

WordPress中的自定义表单并将值存储到自定义数据库中(Custom form in WordPress and store values into custom database)

我有一个简单的表单,在我的WordPress网站中有2个文本字段。 我创建了一个新的页面模板并添加了以下HTML代码:

这是HTML:

<form action="<?php the_permalink(); ?>" id="customform" method="post">
Field 1: <input type="text" name="field1" id="field1">
Field 2: <input type="text" name="field2" id="field2">
<input type="submit" name="submit" id="submit">
</form>

现在我想要实现的是,无论用户输入什么,它都会将它存储到mySQL与WordPress在同一个数据库中 ),例如表test_form

我该如何实现这一目标?


I have a simple form with 2 text fields in my WordPress site. I created a new page template and added the following HTML code:

This is the HTML:

<form action="<?php the_permalink(); ?>" id="customform" method="post">
Field 1: <input type="text" name="field1" id="field1">
Field 2: <input type="text" name="field2" id="field2">
<input type="submit" name="submit" id="submit">
</form>

Now all I want to achieve, is that whatever the user inputs, it stores it to mySQL (which is in the same database as WordPress), in the table test_form, for example.

How do I achieve this?


原文:https://stackoverflow.com/questions/26211294
更新时间:2022-01-03 16:01

最满意答案

我的VB有点生疏,但我相信'ProcErr'不是保留关键字。 这只是VB中的一个命名约定,用于指示在方法(或'procedure',因此名称)发生错误时应该执行的块。

在实际的代码中,然后你有像On Error GoTo ProcErr这样的语句,然后你定义了procerr块:

procErr:
msgbox "an error has happened"

您可以用任何其他名称替换它。 在VB.NET中,你确实会用try catch例程代替它:

Try
// code
Catch x As Type
// exceoption handling
Finally
End Try 'cleanup code

My VB is a bit rusty, but I believe 'ProcErr' is not a reserved keyword. It is just a naming convention in VB to indicate the block that should be executed when an error occurs in your method (or 'procedure', hence the name).

In the actual code, you then have statements like On Error GoTo ProcErr and then you define the procerr block:

procErr:
msgbox "an error has happened"

You could replace this with any other name. In VB.NET you would indeed replace this with a try catch routine:

Try
// code
Catch x As Type
// exceoption handling
Finally
End Try 'cleanup code

相关问答

更多
  • 您对suffix1和suffix2的声明缺少DIM命令: Dim suffix1 As String Dim suffix2 As String 此外,在使用LEN测试Number_To_Words中的长度之前,您需要将单元格中的值转换为字符串。 尝试将测试更改为: Select Case Len(CStr(number)) 另外,检查后缀2中拼写为“syrian”的拼写。 编辑 您可以使用以下稍微更简洁的替代方案替换您的TheOnes功能: Function TheOnes(number As Int ...
  • 这是不平等的运营商 。 可以把它想象成一个类似C语言的版本!= 。 因此1 <> 2计算结果为true,但1 <> 1计算结果为true。 It's the inequality operator. Think of it as C-like languages version of a !=. So 1 <> 2 evaluates to true, but 1 <> 1 does not.
  • 错误,甚至在Visual Basic之前出现的GW Basic和Quick Basic都具有模块化。 False, even GW Basic & Quick Basic which have appeared before visual basic have modularity.
  • 如评论中所述,您不需要希望通过节点到达您想要的节点; 您可以设置整个XPath以查找所需的节点。 但是,您的XML存在一些问题 :它有一个没有前缀的命名空间: 由于所有节点都具有“无法看到”的默认命名空间前缀,因此这会使XPath查询稍微松开,但它仍然存在。 你有三个选择: 1.-从XML中删除命名空间...

  • 这只是猜测,但为了更容易实现和零 - 非零逻辑的灵活性,可能选择逐位的AND / OR / NOT(在8位BASIC实现的时代)。 你不能让语言变得太复杂,因为这回到了“家庭计算机”时代,当时CPU周期以千赫兹为单位,内存以千字节为单位,而存储设备则是罕见的或昂贵的或主要的(例如纸带读取器或匆忙改编的录音机/播放器)。 Dartmouth BASIC(这一切的开头,c 1964, http://bitsavers.trailing-edge.com/pdf/dartmouth/BASIC_4th_Editi ...
  • 我的VB有点生疏,但我相信'ProcErr'不是保留关键字。 这只是VB中的一个命名约定,用于指示在方法(或'procedure',因此名称)发生错误时应该执行的块。 在实际的代码中,然后你有像On Error GoTo ProcErr这样的语句,然后你定义了procerr块: procErr: msgbox "an error has happened" 您可以用任何其他名称替换它。 在VB.NET中,你确实会用try catch例程代替它: Try // code Catch x As Type // ...
  • 您必须使用打印机对象的PaintPicture方法。 例: Printer.PaintPicture LoadPicture(filename), xPosition, yPosition, _ [Width], [Height] 如果您已经在图像或图片控件中加载了图片,则可以传递该对象的图片引用而不是第二次使用LoadPicture。 请注意,此方法不会自动调整图像的大小以适合纸张,因此您必须弄清楚自己要调整图像的大小。 编辑 - ...
  • 手册的英文也不是很好。 我的理解: 您将发送到设备的消息可以表示为字节数组。 您希望将每个字节进行异或运算,这将为您留下一个字节的校验和,并将其添加到消息的末尾。 (字节1 XOR字节2 XOR字节3 XOR ....) “此外”之后的所有内容似乎都说“如果您正在从设备读取,则最终字符是校验和,而不是命令,因此不要将其视为命令,即使它看起来像一个命令。” 您正在写入设备,因此您可以忽略该部分。 要XOR(请记住我不知道VB): 有一个校验和变量,设置为0.循环遍历消息的每个字节,并用该字节对校验和变量进行异 ...
  • 您应该将其放入案例陈述中 Dim ResourceFilePathPrefix As String If System.Diagnostics.Debugger.IsAttached() Then 'In Debugging mode ResourceFilePathPrefix = System.IO.Path.GetFullPath(Application.StartupPath & "\..\..\resources\") Else ...
  • 虽然我认为我所建议的是一个坏主意,但确实有效(或者至少在10年前对我有用)。 在我的情况下,我不得不从VB6(或者可能是VB5)谈论在Linux机器上运行的某些业务逻辑。 我在Linux端向应用程序添加了一个TCP端口侦听器,并通过TCP数据包从VB6与它对话。 我基本上使用TCP作为桥梁。 它实际上工作得很好。 所以你可能会做类似的事情。 但同样,不是一个好主意。 While I think what I am about to suggest is a bad idea, it does work (o ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)