Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 793659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:11:15+00:00 2026-05-14T22:11:15+00:00

Hi I am making a wordpress plugin where I need the Admin to enter

  • 0

Hi I am making a wordpress plugin where I need the Admin to enter data into a database table. I am able to install the db table when the Plugin is activated, however I can’t figure out how to save the user input. I’ve asked on the WP forums but they’re dead… Any experienced guru who can lend some guidance would be greatly appreciated.

<?php



/*******************************************************************
*           INSTALL DB TABLE - ONLY AT RUN TIME                    *
*******************************************************************/
function ed_xml_install() {
global $wpdb;

$ed_xml_data = $wpdb->prefix . "ed_xml_data";
if($wpdb->get_var("SHOW TABLES LIKE '$ed_xml_data'") != $ed_xml_data) {

$sql = "CREATE TABLE " . ed_xml_data . " (
  id mediumint(9) NOT NULL AUTO_INCREMENT,
  name tinytext NOT NULL,
  address text NOT NULL,
  url VARCHAR(55) NOT NULL,
  phone bigint(11) DEFAULT '0' NOT NULL,
  UNIQUE KEY id (id)
);";

  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
  dbDelta($sql);

  $name = "Example Business Name";
  $address = "1234 Example Street";
  $url = "http://www.google.com";
  $phone = "523-3232-323232";

  $insert = "INSERT INTO " . ed_xml_data .
        " (phone, name, address, url) " .
        "VALUES ('" . phone() . "','" . $wpdb->escape($name) . "','" . $wpdb->escape($address) . "', '"  . $wpdb->escape($url) . "')";

  $results = $wpdb->query( $insert );
}
}

//call the install hook
register_activation_hook(__FILE__,'ed_xml_install');

/*******************************************************************
*           CREATE MENU, CREATE MENU CONTENT                       *
*******************************************************************/
if ( is_admin() ){

/* place it under the ED menu */
//TODO $allowed_group = '';

/* Call the html code */
add_action('admin_menu', 'ed_xmlcreator_admin_menu');

function ed_xmlcreator_admin_menu() {
add_options_page('ED XML Creator', 'ED XML Creator', 'administrator', 
'ed_xml_creator',  'ed_xmlcreator_html_page');
}
}

/*******************************************************************
*           CONTENT OF MENU CONTENT                                *
*******************************************************************/


function ed_xmlcreator_html_page() {
<div>
<h2>Editors Deal XML Options</h2>
<p>Fill in the below information which will get passed to the .XML file.</p>
<p>[<a href="" title="view XML file">view XML file</a>]</p>

<form method="post" action="options.php">
<?php wp_nonce_field('update-options'); ?>

<table width="510">
<!-- title -->
<tr valign="top">
<th width="92" scope="row">Deal URL</th>
<td width="406">
<input name="url" type="text" id="url"
value="<?php echo get_option('url'); ?>" />
</td>
</tr>

<!-- description -->
<tr valign="top">
<th width="92" scope="row">Deal Address</th>
<td width="406">
<input name="address" type="text" id="address"
value="<?php echo get_option('address'); ?>" />
</td>
</tr>

<!-- business name -->
<tr valign="top">
<th width="92" scope="row">Business Phone</th>
<td width="406">
<input name="phone" type="text" id="phone"
value="<?php echo get_option('phone'); ?>" />
</td>
</tr>

<!-- address -->
<tr valign="top">
<th width="92" scope="row">Business Name</th>
<td width="406">
<input name="name" type="text" id="name"
value="<?php echo get_option('name'); ?>" />
</td>
</tr>
</table>

<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="hello_world_data" />

<p>
<input type="submit" value="<?php _e('Save Changes') ?>" />
</p>

</form>
</div>

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T22:11:16+00:00Added an answer on May 14, 2026 at 10:11 pm

    First things first, you need a handler on your admin page to do something with the information that’s been posted back. That handler will be the section of code that actually updates your database table.

    The Sample Menu Page in the WP codex has an example of how to check for submitted POST data. Here’s a snipped to work with:

    // mt_options_page() displays the page content for the Test Options submenu
    function mt_options_page() {
    
        // variables for the field and option names 
        $opt_name = 'mt_favorite_food';
        $hidden_field_name = 'mt_submit_hidden';
        $data_field_name = 'mt_favorite_food';
    
        // Read in existing option value from database
        $opt_val = get_option( $opt_name );
    
        // See if the user has posted us some information
        // If they did, this hidden field will be set to 'Y'
        if( isset($_POST[ $hidden_field_name ]) && $_POST[ $hidden_field_name ] == 'Y' ) {
            // Read their posted value
            $opt_val = $_POST[ $data_field_name ];
    
            // Save the posted value in the database
            update_option( $opt_name, $opt_val );
    
            // Put an options updated message on the screen
    
    ?>
    <div class="updated"><p><strong><?php _e('Options saved.', 'mt_trans_domain' ); ?></strong></p></div>
    <?php
    
        }
    
        // Now display the options editing screen
    

    Rather than updating a WordPress option, you’re inserting data into your own table. So I’d replace the update_option( $opt_name, $opt_value); function call with a call to your own function that inserts database information.

    If nothing else, this will give you a start. For a more in-depth example, feel free to browse the code I built for a plug-in called RegLevel. It has a single admin page that allows you to insert information into the database. Take a look at the code to see how it works, maybe you can re-purpose some of it in your own system.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 418k
  • Answers 418k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Your example is only one of the many possible uses… May 15, 2026 at 9:55 am
  • Editorial Team
    Editorial Team added an answer These are just declarations and initializations of byte array variables,… May 15, 2026 at 9:55 am
  • Editorial Team
    Editorial Team added an answer There is no need to have a central repo. That's… May 15, 2026 at 9:55 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.