execute sql query on button click

血红的双手。 提交于 2019-12-06 12:26:59

问题


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";
    }
?>

but for some reason the echo in the nw_check_exec.php is not being executed. please could you help.


回答1:


I think it's because the input type is a "button" and should be a submit:

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


来源:https://stackoverflow.com/questions/12166494/execute-sql-query-on-button-click

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!