Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 提交插入查询,然后重新加载页面_Php_Mysql_Sql - Fatal编程技术网

Php 提交插入查询,然后重新加载页面

Php 提交插入查询,然后重新加载页面,php,mysql,sql,Php,Mysql,Sql,可能重复: 我的页面上有两个提交按钮,每个按钮都将把输入的值插入sql数据库 我希望做的是捕获点击了哪个提交按钮执行相关的insert语句,然后重新加载显示新值的页面。。然而,我只是不知道怎么做 我习惯于这样指定我的职位 <form action="orderform.php" method="post" onsubmit="document.getElementById('myButton').disabled=true; document.getElementById('myButt

可能重复:

我的页面上有两个提交按钮,每个按钮都将把输入的值插入sql数据库

我希望做的是捕获点击了哪个提交按钮执行相关的insert语句,然后重新加载显示新值的页面。。然而,我只是不知道怎么做

我习惯于这样指定我的职位

<form action="orderform.php" method="post"
onsubmit="document.getElementById('myButton').disabled=true;
document.getElementById('myButton').value='Submitting...';"
>


该操作正在指定不同的.php文档。。我想知道一些如何使它,以便当一个提交按钮被选中时,它只是去到当前页面上的一个功能。。这可能吗?如果是这样的话,你能提供一个例子或一个例子的链接吗?因为我不知道这对PHP来说是什么新东西。

如果你在orderform.PHP上,你想访问orderform.PHP上的函数,只需在页面顶部写下PHP即可

您可以通过在submit中添加名称来检测submit按钮,如

<input type="submit" value="Submit" name="submit_first">
完整示例test.php

<?php
      if(isset($_POST['submit_first']))
      echo'this is form the submit first';
  ?>
<html>
    <head></head>
    <body>
        <form name="input" action="test.php" method="POST">
            Username: <input type="text" name="new-user">
            <input type="submit" value="Submit" name="submit_first">
        </form> 
    </body>
</html>

用户名:

如果您在orderform.php上,并且希望访问orderform.php上的函数,只需在页面顶部编写php即可

您可以通过在submit中添加名称来检测submit按钮,如

<input type="submit" value="Submit" name="submit_first">
完整示例test.php

<?php
      if(isset($_POST['submit_first']))
      echo'this is form the submit first';
  ?>
<html>
    <head></head>
    <body>
        <form name="input" action="test.php" method="POST">
            Username: <input type="text" name="new-user">
            <input type="submit" value="Submit" name="submit_first">
        </form> 
    </body>
</html>

用户名:

好的,很酷!谢谢你。。这回答了我试图实现的第一部分。非常感谢much@HurkNburkS你的好,我试过这个。。。我可以看到页面刷新,但是我看不到回声。。你知道为什么吗?@HurkNburkS刚刚在test.php中通过,而不是trycoolio,结果很好。。我现在也可以在数据库中输入值。。对不起,我花了这么长时间才回复你。。我刚刚开始:太酷了!谢谢你。。这回答了我试图实现的第一部分。非常感谢much@HurkNburkS你的好,我试过这个。。。我可以看到页面刷新,但是我看不到回声。。你知道为什么吗?@HurkNburkS刚刚在test.php中通过,而不是trycoolio,结果很好。。我现在也可以在数据库中输入值。。对不起,我花了这么长时间才回复你。。我刚刚开始:P