Chathurika Chathurika - 4 months ago 5
PHP Question

PHP Onclick action for a button

following is my code that I have used,

if ($status=='Pending'){
echo '<td>'.'<a href="leave_request.php?leave_id='.$id1.'"><input type="button" name="submit" class="btn btn-success" value="Approve" "></button></a>'.'</td>'

$result= "UPDATE emp_leaves SET approval_status='Accepted' WHERE leave_id='$id2'";

When user click Accept button, URL will get leave_id of clicked leave_request and will reload page itself. I want to update leave_status column of identified leave_id as 'accepted' while reloading the page. How can I do it.


you are passing value in query string, so $_POST will not work. you need to use $_GET or $_REQUEST.

change your if condition like this.


this might solve your problem.