Hi all,
how to save multiple data of options-page in database, each of which has an id, so that the old data is not overwritten?
I habe created the following basic plugin. When i click on "save changes" button. the input-date (id and mail) will be saved, well so far. But now when I insert new input-date (id and mail), the old input-data in database will be overwritten.
help plzzz
<?php
/**
* @package test
* @version 1.0
*/
/*
Plugin Name: Test
Plugin URI: http://www.test.de
Description:
Author: das ist nur ein Test
Version: 1.0.0
Author URI:
*/
class test{
function __construct() {
add_action('admin_init', array( &$this, 'admin_init' ) );
add_action('admin_menu', array( &$this, 'options_add_menu'));
}
function admin_init() {
register_setting( 'options', 'options', array(&$this,'options_validate' ));
add_settings_section('section', 'General', array(&$this,'general'), 'sf');
add_settings_field('id', 'ID', array(&$this,'id'), 'sf', 'section');
add_settings_field('mail', 'Email', array(&$this,'mail'), 'sf', 'section');
}
function options_add_menu() {
add_options_page('Test', 'Test', 'manage_options', 'sf', array(&$this,'options_add_page'));
}
function options_add_page() {
?>
<div>
<h2>Test</h2>
<form action="options.php" method="post">
<?php settings_fields('options');
?>
<?php do_settings_sections('sf');
?>
<input name="Submit" type="submit" value="<?php esc_attr_e('Save Changes'); ?>" />
</form></div>
<?php
}
function general() {
echo '<p>General Setting </p>';
}
function mail() {
$options = get_option('options');
$value = $options['mail'];
echo "<input id='options[mail]' name='options[mail]' size='40' type='text' value='{$value}' />";
}
function id() {
$options = get_option('options');
$value = $options['id'];
echo "<input id='options[id]' name='options[mail]' size='40' type='text' value='{$value}' />";
}
}
$test = new test;
?>