按下表单按钮时不会执行任何操作

时间:2014-04-03 14:59:49

标签: php html forms

我有一个包含两个按钮的表单 但当我按下其中一个时,没有任何事情发生 我找不到问题你能不能帮帮我!!

这是我的php代码:

    <?php
    session_start(); 
    include 'connection.php';

    // in this section, I retrieve data from database and display them on table 
    // if agree button pressed do the following

 if (isset($_POST['agree']))
    {
$que="update project set status='submitted' ,projectstatus=1 where projectid=$id ";
$result3=mysql_query($que);
        if ($result3)
        {

            echo(" <script>
            alert('The project has been approved');
            </script>");

             header( "Location:unsubmited.php" );

        }
        else
        {
            echo "an error occur can't agree on this project";
        }


    }
    ?>

这是表格:

<form action='' method='post'>
   <input type='button' name='disagree' value='disagree ' class='styled-button-11'>
   <input type='button' name='agree' value='agree' class='styled-button-11'>
   </form>

thanx ^^

2 个答案:

答案 0 :(得分:2)

更改你的代码,正如andrewsi所说:

<form action='' method='post'>
<input type='submit' name='disagree' value='disagree ' class='styled-button-11'>
<input type='submit' name='agree' value='agree' class='styled-button-11'>
</form>

答案 1 :(得分:1)

我相信这很简单,填写action=''到页面以回复并设置type='submit'作为andrewsi建议。

相关问题