0

我的页面上有两个表格。但是一个操作页面(approve.php)似乎不起作用。如果它被批准或拒绝,我需要将一个字段设置为特定 ID 的活动。有没有办法在一个操作页面上做到这一点?

或者我在下面做错了什么?我屏蔽了插入脚本,因为我不知道它是否会导致问题。当我第一次批准时,它正在工作......

页:

<form method="get" action="approve.php">
            <input type="hidden" name="rows" value="<?php echo $row[0] ?>" />
            <p><a href='approve.php?id=<?php echo $row[0] ?>'><button url="#" class="btn btn-primary">Approve</button></a></p>
            </form>
            <form method="get" action="reject.php">
            <div id="reject-form-<?php echo $row[0] ?>" class="modal hide fade">
                        <div class="modal-header">
                            <a class="close" data-dismiss="modal">&times;</a>
                            <h3><?php _e('Reject Reason'); ?></h3>
                        </div>
                        <div class="modal-body">
                            <div id="message"></div>
                        <div class="controlgroup forgotcenter">
                                <div class="control">
                                    <input id="reject" name="reject" type="text"/>
                                </div>
                        </div>
                </div>
                <div class="modal-footer">
                    <input type="hidden" name="rw_id" value="<?php echo $row[0] ?>" />
                    <a href='reject.php?id=<?php echo $row[0] ?>'><button data-complete-text="<?php _e('Done'); ?>" class="btn btn-primary pull-right" id="forgotsubmit"><?php _e('Submit'); ?></button></a>
                    <p class="pull-left"><?php _e('Please give a short reason for rejecting.'); ?></p>
                    </div>
                </div>
            <p><a data-toggle="modal" href="#reject-form-<?php echo $row[0] ?>" id="rejectlink" tabindex=-1><button url="#" class="btn btn-primary">Reject</button></a></p>
            </form>

拒绝:

$id = $_GET['rw_id'];
    $reason = $_GET['reject'];


    $dbc = mysqli_connect('localhost', 'root', 'root', 'adjudication') or die('Connection error!');

    $update = "UPDATE login_fines_adjudicated SET reject_reason = '$reason' WHERE id ='$id'";
    mysqli_query($dbc, $update) or die('Database error!');

    $update1 = "UPDATE login_fines_adjudicated SET active = 1 WHERE id ='$id'";
    mysqli_query($dbc, $update1) or die('Database error, fine!');

    header('location:adjudication.php');

批准:

$id = $_GET['rows'];

    $dbc = mysqli_connect('localhost', 'root', 'root', 'adjudication') or die('Connection error!');

    $updated = "UPDATE login_fines_adjudicated SET active = 1 WHERE id = '$id'";
    mysqli_query($dbc, $updated) or die('Database error, active!');

    /**$insert = "INSERT INTO login_fines(`date`, `time_in`, `time_out`, `value`, `area`, `reason`, `licence`)"
    ." SELECT `date_issued`, `time_arrived`, `time_departed`, `value`, `location`, `violation_reason`, `licence`"
    ." FROM login_fines_adjudicated WHERE id = '$id'";
    mysqli_query($dbc, $insert) or die('Database error, fines!');**/

    header('location:adjudication.php');

任何帮助,将不胜感激!

4

2 回答 2

0

您必须像这样更改代码:

<form method="get" action="approve.php?id=<?php echo $row[0] ?>">
    <p>
        <input type="submit" class="btn btn-primary" value="Approve" />
    </p>
</form>
于 2013-06-03T11:18:01.703 回答
0

你遇到了什么错误?如果您发布错误,我可以提供帮助您是否调试了从表单中获得的值?你得到了什么?

您可以在一个脚本中结合拒绝和批准,并根据传入的值采取不同的行动。我认为 post 比 get 更好

<form method="post" action="approve.php">
 <input type="hidden" name="approve" value="<?php echo $row[0] ?>" />
  <p><a href='approve.php?id=<?php echo $row[0] ?>'><button url="#" class="btn btn-     primary">Approve</button></a></p>
</form>

<form method="post" action="reject.php">
 <div id="reject-form-<?php echo $row[0] ?>" class="modal hide fade"> 
 ....
<input type="hidden" name="reject" value="<?php echo $row[0] ?>" />

在 action.php 中,

if(key_array_exists($_POST['approve'])) ...
if(key_array_exists($_POST['reject'])) ...
于 2013-07-30T13:54:16.223 回答