0

This website say I can't put too many code. So I put these pictures for intance.

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>

when I clicked the submit button, it didn't work. But when I clicked the reset button , it works.

Here is a animation. enter image description here enter image description here

Do I need to submit any other information?

===update===

when I changed:

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

TO:

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

It works.

Why? enter image description here

5
  • you have to make sure the action on the form. Check for the same. if still not works, try button tag instead of the input type submit Commented Jun 11, 2020 at 7:45
  • and also check the validation on the input fields. Commented Jun 11, 2020 at 7:46
  • I have updated the question.Could you take a look again for me?@BirendraSingh Commented Jun 11, 2020 at 7:54
  • Check the actual HTML output your PHP is creating … Commented Jun 11, 2020 at 7:58
  • console output: ``` [Deprecation] Resource requests whose URLs contained both removed whitespace (\n, \r, \t) characters and less-than characters (<) are blocked. Please remove newlines and encode less-than characters from places like element attribute values in order to load these resources. See chromestatus.com/feature/5735596811091968 for more details. ``` Commented Jun 11, 2020 at 8:00

2 Answers 2

1

replace your this section

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

with

<?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 ; ?>">
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you!@Majid Ahmadi
0

check form alonely becouse your form alonely worked maybe prevent to submit in another section of page with javascript

3 Comments

I have updated the question.Can you take a look again for me?@Majid Ahmadi
send all of content in your document , becouse your form alonely worked in both times
I have uploaded it as pictures.@Majid Ahmadi

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.