Php WordPress博客上的自定义表单

Php WordPress博客上的自定义表单,php,forms,wordpress,Php,Forms,Wordpress,我想为我的WordPress博客创建一个自定义表单,该表单获取用户的电子邮件地址,然后将其添加到数据库中。我知道如何编写表单和脚本来实现数据存储。不过,我不知道如何才能把它贴在WordPress的博客上 这类东西有没有插件,或者有没有办法手动将表单添加到页面 它基本上是一个注册通知框 谢谢。如果您的主题已经就绪,您可以使用文本小部件添加它 在外观>小部件下查看 您可以将html添加到文本小部件如果您使用的html多于html,则小部件将出现问题。在此基础上,我建议您自己创建一个小部件 下面是一个

我想为我的WordPress博客创建一个自定义表单,该表单获取用户的电子邮件地址,然后将其添加到数据库中。我知道如何编写表单和脚本来实现数据存储。不过,我不知道如何才能把它贴在WordPress的博客上

这类东西有没有插件,或者有没有办法手动将表单添加到页面

它基本上是一个注册通知框


谢谢。

如果您的主题已经就绪,您可以使用文本小部件添加它

在外观>小部件下查看
您可以将html添加到文本小部件

如果您使用的html多于html,则小部件将出现问题。在此基础上,我建议您自己创建一个小部件

下面是一个空白插件的代码。在“小部件”功能中添加/调用代码

<?php
/*
Plugin Name: Blank Plugin
Plugin URI: http://www.example.com/plugins/blankPlugin/
Description: This is a plugin template
Author: Your Name
Version: 0.1
Author URI: http://www.example.com/about/
*/

class blankPlugin extends WP_Widget {

 function blankPlugin() {  // The widget construct. Initiating our plugin data.
  $widgetData = array( 'classname' => 'blankPlugin', 'description' => __( "A blank plugin widget" ) );
  $this->WP_Widget('blankPlugin', __('Blank Plugin'), $widgetData);
 } 

 function widget($args, $instance) { // Displays the widget on the screen.
  extract($args);
  echo $before_widget;
  echo $before_title . $instance['title'] . $after_title; 
  echo 'The amount is: '.$instance['amount'];
  echo $after_widget;
 }

 function update($new_instance, $old_instance) { // Updates the settings.
  return $new_instance;
 }

 function form($instance) { // The admin form. 
  $defaults = array( 'title' => 'Wichita', 'amount' => '45' );
  $instance = wp_parse_args($instance, $defaults); ?>
  <div id="blankPlugin-admin-panel">
   <p>
    <label for="<?php echo $this->get_field_id("title"); ?>">Widget title:</label>
    <input type="text" class="widefat" name="<?php echo $this->get_field_name("title"); ?>" id="<?php echo $this->get_field_id("title"); ?>" value="<?php echo $instance["title"]; ?>" />
   </p>
   <p>
    <label for="<?php echo $this->get_field_id("amount"); ?>">An amount:</label>
    <input type="text" class="widefat" name="<?php echo $this->get_field_name("amount"); ?>" id="<?php echo $this->get_field_id("amount"); ?>" value="<?php echo $instance["amount"]; ?>" />
   </p>
  </div>
<?php } 

} 

// Register the widget.
add_action('widgets_init', create_function('', 'return register_widget("blankPlugin");'));
?>


有关更多信息。。。(也请参见页面底部的链接)
您可以使用这个wordpress插件

或者你可以自己做

您可以在主题文件夹中创建一个模板,如下所示:-

<?php
/*Template Name: some thing*/
//your dynamic stuff here

?>

并且可以将此模板分配给您的静态页面,您可以从wordpress的管理面板创建该页面。每当你点击这个静态页面的参数,这个文件就会被调用。 因此,您可以处理所有邮件内容等。
谢谢。

因为我从HTML调用PHP脚本来处理表单,它需要在iFrame中吗?我想如果不是这样的话,整个博客将被重定向到处理脚本。我添加了一个iframe,然后加载表单。所以重定向不是问题。谢谢你的解决方案。