Hi guys,

I am using a number of checkboxes and I want to get their value using POST method, but my problem is that I use two buttons at the end! Buttons "Accept" and "Reject"
If accept is pressed I want to know it so I can make different process on them, if reject is pressed again I want to know it.

Here is what I use up to know but I haven't manage to get it work if reject is pressed instead of accept

<?php
 
   $value = $_POST['chk'];
 
   //if accept is pressed
   //do this...
   //else if reject is pressed
   //do this...

?>

<form action='test.php' method='post'>
<input type='checkbox' name='chk[]' value='value1'>VALUE 1<br>
<input type='checkbox' name='chk[]' value='value2'>VALUE 1<br>
<input type='checkbox' name='chk[]' value='value3'>VALUE 1<br>
<input type='checkbox' name='chk[]' value='value4'>VALUE 1<br>
<input type='submit' name='submit' value='Accept'>
<input type='submit' name='submit' value='Reject'>
</form>

Recommended Answers

All 3 Replies

//if accept is pressed
if ($_POST == 'Accept') {
//do this...
}
//else if reject is pressed
if ($_POST == 'Reject') {
//do this...
}

if($problem == "solved"){
  clickLink("mark_as_solved");
}
commented: great and works perfect +0

works perfect mate, thanks a lot ;)

Please mark this thread as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.