What i'm trying to do is: I have one radio button and should have 2 values one "Y" and the other "N". User has chosen from drop down list a name and if he wants he can grand or remove administrative role for this persons name (I have other buttons also all of them have the same name as this radio button):
<input type="radio" name="radio" value="<?php
if ($r['admin']=='N' && $r['username']==$un){ print "Y\"> Grant Administrator Role<br>";}
if ($r['admin']=='Y' && $r['username']==$un){ print "N\"> Revoke Administrator Role<br>";}
?>
$un is
$_SESSION['username']=$_POST['username'];
$un=$_SESSION['username']
So if this chosen name has in db for admin attribute value of "N" the radio button needs to say Grant Administrator Role and if in db the value is "Y" the radio button needs to say Revoke Administrator Role.
I'm having a hard time to update the value in db when this radio button is selected. Here is my code so far:
if($_SESSION['status']=='Y'){
$qadmin="UPDATE users SET admin='{$_SESSION['status']}' WHERE username='{$_SESSION['username']}'";
$qa=mysqli_query($dbc,$qadmin);
print "selected radio is ".$_SESSION['status']."username ".$_SESSION['username'];
//header("Location: status.php");
}
if($_SESSION['status']=='N'){ $qadmin="UPDATE users SET admin='{$_SESSION['status']}' WHERE username='{$_SESSION['username']}'"; $qa=mysqli_query($dbc,$qadmin); print "selected radio is ".$_SESSION['status']."username ".$_SESSION['username']; //header("Location: status.php"); }
The result that I'm getting here is: When the chosen username is with value in db "N" the update is done correctly, but when the username has value of "Y" and the radio button says now Revoke Administrator Role the value of the $_SESSION['status'] is again "Y".
I know I must miss something very simple but I cant figure it out. Please advise and sorry form my very very long question. Thank you in advance