【问题标题】:Form submit button isn't working?表单提交按钮不起作用?
【发布时间】:2016-09-18 14:09:42
【问题描述】:

我以前遇到过这个问题,所以我通常总是使用“<input type='submit' ... >”但是我希望有一个 bin 图像作为按钮而不是文本(显然是创建一个删除按钮)。为了让我这样做,我需要使用按钮标签,但是 PHP 代码不起作用。

HTML:

<form action='#' method='POST'>
  <button type='submit' name='form-wallpostdelete'>Delete</button>
</form>

PHP:

$delete_post = @$_POST['form-wallpostdelete']; //Form variable

if($delete_post) {
    echo "Deleted";
}
?>

真的很简单,当我使用“input type='submit' name='form-wallpostdelete' value='Delete'>”时,它可以工作,并且消息会回显,但是当我使用按钮时,页面只会刷新.

【问题讨论】:

    标签: php html forms button input


    【解决方案1】:
    Use isset() method for checking  
    <form action='#' method='POST'>
          <button type='submit' name='form-wallpostdelete'>Delete</button>
        </form>
        <?php 
        $delete_post = @$_POST['form-wallpostdelete']; //Form variable
    
        if(isset($delete_post)) {
            echo "Deleted";
        }
        ?>
    

    【讨论】:

      猜你喜欢
      • 2015-10-10
      • 2020-08-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-11
      相关资源
      最近更新 更多