php:单击“提交”按钮,但该按钮不起作用

时间:2020-06-11 07:27:08

标签: php html forms

这个网站说我不能放太多代码。所以我把这些图片作为实例。

enter image description here enter image description here enter image description here

<form name="form1" method="post" action='doAction.php?option=add&a=<?php echo $_GET["id"]?"update&id=".$_GET["id"]:"add";?>'>
                        <table width="820px" height="500px" border="0" cellpadding="0" bgcolor="#FFFFFF">
                            <tr>
                                <td width="500px" align="center" style="font-size:20px;line-height: 100px"><div>公告主题:</div></td>
                                <td width="500px" height="50px">
                                    <input name="title" type="text" id="txt_title" size="40"
                                           style="width: 500px; height: 50px"
                                           value="<?php
                                    $result = null;
                                    if ($id = $_GET['id']) {
                                        //1.导入配置文件和Model类
                                        require("config.php");
                                        require("Model.php");
                                        $mod = new Model('tb_notice');                     //实例化类
                                        $result = $mod->find($id);                         //调用find()方法
                                        echo $result['title'];                         //读取标题字段
                                    }?>">
                                </td>
                            </tr>
                            <tr>
                                <td height="500px" align="center" style="font-size: 20px">公告内容:</td>
                                <td><textarea name="content" cols="60" rows="40" style="width: 500px; height: 400px;margin: 0px;"
                                              id="txt_content" value="<?php echo $result['content']?>"></textarea></td>
                            </tr>
                            <tr>
                                <td height="40" colspan="2" align="center">
                                    <input  type="submit" name="Submit" id="Submit" value="修改/添加">
                                    &nbsp;<input type="reset" name="Submit2" id="Submit2" value="重置"></td>
                            </tr>
                        </table>
                    </form>

当我单击“提交”按钮时,它不起作用。但是,当我单击“重置”按钮时,它可以工作。

这是动画。 enter image description here enter image description here

我还需要提交其他信息吗?

===更新===

当我更改时:

<form name="form1" method="post" action="doAction.php?option=add&a=<?php if ($_GET['id']) {
    echo "update&id=$_GET[id]";
    } else {
        echo "add";
    } ?>">

收件人:

<form name="form1" method="post" action="doAction.php?option=add&a=add">

有效。

为什么? enter image description here

2 个答案:

答案 0 :(得分:1)

替换您的本节

<form name="form1" method="post" action='doAction.php?option=add&a=<?php echo $_GET["id"]?"update&id=".$_GET["id"]:"add";?>'>

<?php
    $str = "add"; 
    if(isset($_GET['id']) && $_GET['id'])
    {
        $str = "update&id=".$_GET['id'];
    }
?>
<form name="form1" method="post" action="doAction.php?option=add&a=<?php echo $str ; ?>">

答案 1 :(得分:0)

单独检查表格,因为您的表格单独工作 可能阻止使用javascript在页面的另一部分提交