按钮单击执行sql查询

时间:2012-08-28 19:48:09

标签: sql button click exec

nw_check.php

<?php
  $con = mysql_connect("localhost","root","12345");
  if (!$con)
  {
    die('Could not connect: ' . mysql_error());
  }
?>

 <html>
 <body>
    <form method="POST" action="nw_check_exec.php">
        <input type="button" name="nw_update" value="NW_Update"/>
    </form>
</body>
</html>

nw_check_exec.php

<?php
    if(isset($_POST['nw_update'])){
        echo("You clicked button one!");
        //and then execute a sql query here
    }
    else {
    echo" dhur";
    }
?>

但由于某种原因,nw_check_exec.php中的回显未被执行。拜托,求你帮忙。

1 个答案:

答案 0 :(得分:2)

我认为这是因为输入类型是“按钮”,应该是提交:

<input type="submit" name="nw_update" value="NW_Update"/>