I have two forms on my page. But the one action page(approve.php) doesn't seem to work. I need to set a field as active for the specific id, if it's approve or rejected. Is there any way to do it on one action page?
Or is there something I am doing wrong below? I blocked out the insert script because I didn't know if it was causing an issue. It was working before when I did the approval first...
Page:
<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>
Reject:
$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');
Approve:
$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');
Any help would be appreciated!
What error are you getting? I can help if you post the error Have you debug the value you get from the form? what do you get?
You can combine reject and approve in one script, and act different based on the value passed in. and I think post is better than get
in action.php,
You have to change your code like this :