I am making a plugin with a setting page in it. In its setting page I need a user registration form with only two fields: username and password. How can I save this data to the database?
Here is what I am trying to do:
public function PLUGIN_setting_page(){
require_once PLUGIN_PATH. 'templates/admin/plugin-settings.php';
}
plugin-settins.php
:
<?php
if(isset($_POST['submit'])) {
global $wpdb;
$table = 'wp_myp_user';
$data = array(
'username' => $_POST['username'],
'password' => $_POST['password']
);
$format = array(
'%s',
'%s'
);
$success=$wpdb->insert( $table, $data, $format );
if($success){
echo 'data has been save' ;
}
}
?>
<div class="login-page">
<div class="form" method="post" action="">
<form class="login-form">
<input type="text" name="ldc_username" placeholder="username" value=""/>
<input type="password" name="ldc_password" placeholder="password" value=""/>
<!-- <button type="submit">login</button> -->
<?php submit_button(); ?>
</form>
</div>
</div>