我正在开发一个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>发布于 2015-02-06 02:04:34
您可以尝试将其添加到HTML中:
<?php if (!empty($_POST['ATE-submitButton'])): ?>
<script>
alert('Form Submitted');
</script>
<?php endif ?>https://stackoverflow.com/questions/28357381
复制相似问题