我正在开发一个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>
答案 0 :(得分:1)
您可以尝试将其添加到HTML中:
<?php if (!empty($_POST['ATE-submitButton'])): ?>
<script>
alert('Form Submitted');
</script>
<?php endif ?>