如何检测按钮是否被单击


How to detect if a button is clicked or not

我这里有一个简单的php编码问题。我有一个按钮id '注册'用户点击。但是,一旦单击按钮,下面的代码不会运行它。

<?php
try {
 if (isset($_POST['register'])) {
    require_once('library.php');
    $user_id = $identity->user_id; 
    $status_type = 'M';
    $data = array('status' => $status_type);
    $dbWrite->update('user', $data, "user_id = $user_id");
    header('Location: main.php');
    exit;
 }
} catch (Exception $e) {
  echo $e->getMessage();
}

有人能帮我吗?

按钮的Name属性必须被忽略。在HTML中定义按钮,如下所示

<input type="submit" name="register" value="register" />

print_r($_POST);,看看缺少什么

可能是form的语法