php - Stay on same page after form submit within WordPress -


i've added html page part of admin wordpress (see screenshot)

html page in wordpress

and i'm trying on each submit button, if record added database pop shows saying "success!" , clear form data without leaving page. @ moment current set tries load external page instead of remaining on page in screenshot. here's html , php:

<form class="pure-form" name="addathlete" action="submitform.php" method="post">     <fieldset class="pure-group">         <input type="text" class="pure-input-2" name="membershipid" placeholder="membership id">          <input type="text" class="pure-input-2" required="required" name="firstname" placeholder="first name">          <input type="text" class="pure-input-2" required="required" name="surname" placeholder="surname">     </fieldset>      <button name="submitathlete" type="submit" class="pure-button pure-input-2 pure-button-primary">submit</button> </form>  <?php function showsuccess() {     echo "success! 1 record added."; }  if (isset($_post['submitathlete'])) {     addathlete(); }  function addathlete() {     include 'addathlete.php';     showsuccess(); } ?> 

i'm assuming problem lies fact echo "success" trying echo on submitform.php page how i've written it. because of way page embedded wordpress, can see below:

add_action( 'admin_menu', 'db_menu' );  function db_menu() {     add_menu_page(     'database form',     // page title     'database form',     // menu title     'manage_options',   // capability     'database-form',     // menu slug     'wpse_91693_render' // callback function     ); }  function wpse_91693_render() {     global $title;      print '<div class="wrap">';     print "<h1>$title</h1>";      $file = plugin_dir_path( __file__ ) . "submitform.php";      if ( file_exists( $file ) )     require $file;      print '</div>'; } 

how can pop or show within wordpress page on each submit?

thanks!

when submit form, posts data new webpage loading it. in order stay on same page, action should take same page ( move processing logic there aswell, checking posted arguments ) or if don't want see reload, use ajax instead.


Comments

Popular posts from this blog

rdbms - what exactly the undo information lives in oracle? -

bash - How do you programmatically add a bats test? -

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -