Saving data from an input
-
I am writing an options page for a plugin I am developing and am having huge trouble saving any data from it.
I need to be able to access the information from several inputs in other php files and scripts, but haven’t even been able to save the damn thing set.
I can’t use the settings API as it is too gerneric (doesn’t meet the layout requirements of the client), so I am having to handball everything.
In my main file, I have this:
function LoadPress_Email() { if ( !current_user_can( 'manage_options' ) ) { wp_die( __( 'You do not have sufficient permissions to access this page.' ) ); } if (isset($_POST['fromValue'])) { update_option('fromValue', $_POST['fromValue']); $value = $_POST['fromValue']; } $value = get_option('fromValue', 'Example'); include 'LoadPressOptions-Email.php'; }Which is called by an add_submenu_page call.
Inside the LoadPressOptions-Email.php file, I have this:
<input value="<?php echo $fromValue; ?>" style="height:40px;" type="text" id="fromValue" placeholder=""From" Text" class="emailInput" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false">
and<?php if (isset($_POST['fromValue'])) { update_option('fromValue', $_POST['fromValue']); $fromValue = $_POST['fromValue']; } $fromValue = get_option('fromValue'); ?>The actual file is over 200 lines long so I can’t exactly post that here, but this is the only bit of “functional” code I have in there (or should function anyway).
My understanding of this is that it should get the FromValue value and store it…somewhere when the submit button is clicked, but it doesn’t seem to at all.
The topic ‘Saving data from an input’ is closed to new replies.