I'm trying to redirect a user after a onclick action but the userid in the following code always remains the same regarless the user chosen in the table. Maybe I'm missing something here...
<td>
<?php if ($memberinfo['UserIsChecked'] == 1){ ?>
<button class="btn btn-xs btn-icon btn-default"> <i class="fa fa-times"></i> </button>
<?php } else { ?>
<a href="#"><p onclick="go()">Approve/Refuse <?php echo($memberinfo['UserId']) ;?></p></a>
<script>
var userid='<?php echo $userid;?>';
function go(){
swal({
title: 'Are you sure?',
text: "You won't be able to revert this!",
type: 'warning',
showCancelButton: true,
confirmButtonText: 'Validate user',
cancelButtonText: 'Refuse request',
confirmButtonClass: 'btn btn-success',
cancelButtonClass: 'btn btn-danger m-l-10',
buttonsStyling: false
}).then(function () {
swal(
'User validated!',
'The user has been notified.',
'success',
).then(function(){
window.location = 'scripts/process-validate-user.php?userid='+ userid +' ' ;
})
}, function (dismiss) {
// dismiss can be 'cancel', 'overlay',
// 'close', and 'timer'
if (dismiss === 'cancel') {
swal(
'User refused',
'The user has been notified.',
'error'
)
}
})
}
</script>
<?php } ?>
</td>