我的页面上有两个表单。但是一个动作页面(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">×</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');
任何帮助将不胜感激!
答案 0 :(得分:0)
您必须像这样更改代码:
<form method="get" action="approve.php?id=<?php echo $row[0] ?>">
<p>
<input type="submit" class="btn btn-primary" value="Approve" />
</p>
</form>
答案 1 :(得分:0)
你得到什么错误?如果您发布错误,我可以提供帮助 您是否调试了从表单中获得的值?你得到了什么?
您可以在一个脚本中组合拒绝和批准,并根据传入的值执行不同的操作。我认为帖子比获取更好
<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] ?>" />
in action.php,
if(key_array_exists($_POST['approve'])) ...
if(key_array_exists($_POST['reject'])) ...