简体   繁体   中英

WordPress Plugin Form Not Submitting

I am developing a WordPress plugin which has a form.I am having trouble getting the php file to recognize that a form has been submitted. The idea is once i hit the submit button, then the page will reload and alert "Form Submitted"

PHP

add_shortcode('show_game_form','ate_form_activate');
function ate_form_activate(){
  if(is_page('Commercial'))
  {

  if(isset( $_POST['ate-final-submi'] ))
    { 
      //NOT ALERTING!!!!!!
      echo "<script type='text/javascript'> alert('Submitted Form'); </script>";
    }
    //Display Page
    $myfile = fopen("/ATE-Form/index.html", "r") or die("Unable to open file!");
    echo fread($myfile,filesize("/ATE-Form/index.html"));
    fclose($myfile);

    return  "";
  }
}

HTML

<form id="ate-final-submi" name="ate-final-submi"  method="post" action=""><br>
    <input type="text" id="ate-final-email" name="ate-final-email" value="asfd">
    <button type="button" id="ATE-backButton" class="ATE-nav-button">« Back</button>  
    <button type="submit" name="ATE-submitButton" id="ATE-submitButton" class="ATE-nav-button">
</form>

You may try adding this to your HTML:

<?php if (!empty($_POST['ATE-submitButton'])): ?>
   <script>
     alert('Form Submitted');
    </script>
<?php endif ?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM