Html+PhP 提交按钮不起作用


Html+PhP Submit button not working

所以,我是这里的新手,也是 html 的新手,我正在阅读一些网站(现在已经几个小时了(,据我所知,我的代码应该可以工作,但它没有......我只想单击一个按钮并接收它的名称作为回声。但是当我点击笔记发生时。有什么好心人帮忙吗?:P

<head>
    <title>Index</title>
</head>
<body>
    <div>
        <input type="submit" name="insert" value="insert" >
        <input type="submit" name="select" value="select" >

    </div>
    <?php
        if (isset( $_GET['insert'])) {
            echo "insert";
        }
        if ( isset( $_GET['select'] ) ) {
            echo "select";
        }
    ?>
</body>

提交按钮适用于表单,因为只能提交表单,因此您可以尝试使用:

<form method="get" name="frm">
<input type="submit" name="select" value="select" >
</form>

请将您的div插入到类似

<head>
    <title>Index</title> 
</head> 
<body>
    <form  method="get" action="">
        <div>
            <input type="submit" name="insert" value="insert" >
            <input type="submit" name="select" value="select" >

        </div>
    </form>
        <?php
            if (isset( $_GET['insert'])) {
                echo "insert";
            }
            if ( isset( $_GET['select'] ) ) {
                echo "select";
            }
        ?>
    </body>

只需添加这样的表单标签

<form>
<input type="submit" name="insert" value="insert" >
<input type="submit" name="select" value="select" >
</form>

您可以编写表单标签或在页面右上角使用以下代码

if(isset($_POST['insert'])){
...
}
 if(isset($_POST['select'])){
 ...
 }

检查这个

<html>
<head>
<title>Index</title>
</head>
<body>
    <div>
        <form method="GET" action="#">
        <input type="submit" name="insert" value="insert" >
        <input type="submit" name="select" value="select" >
        </from>
    </div>
</body>
</html>
    <?php
        if (isset( $_GET['insert'])) {
            echo "insert";
           }
        if ( isset( $_GET['select'] ) ) {
            echo "select";
           }
    ?>

请先在表单中定义方法。

<form method="GET" action="#">
<input type="submit" name="insert" value="insert" >
<input type="submit" name="select" value="select" >
</form>