I am working on a plugin where a new page template is created on plugin activation. The template has a form for user input.
<form action="" method="post">
<textarea name="question"></textarea>
<input type="submit" name="submit_question">
</form>
Value is properly stored in following way:
if ( isset( $_POST[ 'submit_question' ] ) ) {
$wpdb->insert(
$table_name,
array( 'question' => $question,
'created_at' => $created_on
),
array( '%s', '%s' )
);
}
The issue is, if the page is reloaded after form submission, its restoring the values again. How can I clear the values after submission? Or redirect properly? I tried some solutions (e.g. wp_redirect
) but not getting any result. Please help.