javascript - WordPress 插件表单未提交

标签 javascript php wordpress forms

我正在开发一个带有表单的 WordPress 插件。我无法让 php 文件识别表单已提交。这个想法是一旦我点击提交按钮,页面就会重新加载并提醒“表单已提交”

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>

最佳答案

您可以尝试将其添加到 HTML 中:

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

关于javascript - WordPress 插件表单未提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28357381/

相关文章:

javascript - AngularJS - 三个依赖选择 - 只有前两个填充

php - Codeigniter:在for循环中设置上传文件名

php - WordPress 分页无法正常工作

javascript - 在js代码中分配作用域变量

javascript - 两个不相等的相同字符串

javascript - 使用 javascript 从通过 JSON 返回的域获取 TXT 记录

Windows 和 IIS 上的 PHP 5 和 Zend MVC

php - 更多 PHP mySQL INSERT 乐趣

php - Wordpress 无法连接到非常小的站点中的 DB : Too Many Connections,

html - 如何从wordpress中删除页脚 "powered by wordpress"