title: save and retrieve custom plugin options input
body: <p>I'm new to creating wordpress plugin. I want to create a plugin that display custom page option under setting options of wp-admin section and to save the value of input data and retrieve it, I have gone through the tutorial of <a href="http://ottopress.com/2009/wordpress-settings-api-tutorial/" rel="nofollow noreferrer">otto press</a></p>
  
  <p>I created a folder in <code>wp-content/plugin/</code> named <code>new-setting-plugin</code> inside the folder is a file named <code>new-setting-plugin.php</code> so the entire file path is <code>wp-content/plugin/new-setting-plugin/new-setting-plugin.php</code></p>
  
  <p>the code of the file new-setting-plugin.php is given at the end of the table. After creating the code I went onto plugin page of wp-admin and installed the plugin, it was all fine. </p>
  
  <p>Now when i press "Save setting" button it shows the message "Setting saved" but i can't see the value inside the input fields</p>
  
  <p>I'm attaching my images to preview what it is appearing in my plugin page</p>
  
  <p>When go to the plugin page i see the following input fields:
  <img src="https://i.stack.imgur.com/R27zJ.png" alt="New Setting Page"></p>
  
  <p>Now I'm entering the value to input fields:
  <img src="https://i.stack.imgur.com/h2jSH.png" alt="Entering the fields"></p>
  
  <p>When I clicked the "Save Setting" button i got the following message after page refreshed
  <img src="https://i.stack.imgur.com/XIS7v.png" alt="Page after submit action"></p>
  
  <p>Here is my code</p>
  
  <pre><code>&lt;?php
  
  add_action('admin_menu', 'add_page');
  
  if ( !function_exists( 'add_page' ) ) {
  
      //function to add page under setting options in wordpress admin section
      function add_page() {
          add_options_page('New Setting Page', 'New Setting', 'manage_options', 'plugin', 'plugin_options_frontpage');
  
      }
  
  }
  
  function plugin_options_frontpage() {
  
  ?&gt;
  
  &lt;div class="wrap"&gt;
  &lt;?php screen_icon('users'); ?&gt;&lt;h2&gt;New Setting Page title&lt;/h2&gt;
  
  &lt;form action="options.php" method="post"&gt;
  
  &lt;?php settings_fields('plugin_options'); ?&gt;
  &lt;?php do_settings_sections('plugin'); ?&gt;
  &lt;table class="form-table"&gt; 
  
    &lt;tr valign="top"&gt;
  
      &lt;td colspan="2"&gt;
          &lt;input name="Submit" type="submit" class="button button-primary" value="&lt;?php esc_attr_e('Save Changes'); ?&gt;" /&gt;
      &lt;/td&gt;
  
    &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/form&gt;
  
  &lt;/div&gt;
  
  &lt;?php
  
  }
  
  
  add_action('admin_init', 'plugin_admin_init');
  function plugin_admin_init(){
  register_setting( 'plugin_options', 'plugin_options', 'plugin_options_validate' );
  add_settings_section('plugin_main', 'Main Settings', 'plugin_section_text', 'plugin');
  add_settings_field('plugin_text_input1', 'Input 1', 'plugin_input1', 'plugin', 'plugin_main');
  add_settings_field('plugin_text_input2', 'Input 2', 'plugin_input2', 'plugin', 'plugin_main');
  }
  
  function plugin_section_text() {
  echo '&lt;p&gt;New input setting to be saved.&lt;/p&gt;';
  }
  
  function plugin_input1() {
  $options = get_option('plugin_options');
  echo "&lt;input id='plugin_input1' class='normal-text code' name='plugin_options[text_string]' size='30' type='text' value='{$options['text_string']}' /&gt;";
  }
  
  
  function plugin_input2() {
  $options = get_option('plugin_options');
  echo "&lt;input id='plugin_input2' class='normal-text code' name='plugin_options[text_string]' size='30' type='text' value='{$options['text_string']}' /&gt;";
  }
  
  
  function plugin_options_validate($input) {
  $options = get_option('plugin_options');
  $options['text_string'] = trim($input['text_string']);
  if(!preg_match('/^[a-z0-9]{32}$/i', $options['text_string'])) {
  $options['text_string'] = '';
  }
  return $options;
  }
  
  ?&gt;
  </code></pre>
  
  <p>What wrong in my code, How can I correct my code and is there a way to show the value of input fields outside the field in same page in a table?</p>