<?php
	session_start();
	if($_SESSION['unohs'] == null){
		header("location:index.php?msg=unauthorized");
	}
?>
<?php
	include ("conn.php");		
	
	if(isset($_POST['upiid'])){
		$a_id = $_POST['upiid'];
		$sql_s = "SELECT * FROM tbl_pg WHERE value = '".$a_id."'";
		$run = mysqli_query($conn, $sql_s);
		//Set status to 0
		$sql_d = "SELECT * FROM tbl_pg WHERE status = '1'";		
		$run_d = mysqli_query($conn, $sql_d);
		$rund_f = mysqli_fetch_array($run_d);
		$ch_s0 = "UPDATE tbl_pg SET status='0' WHERE id='".$rund_f['id']."'";
		$exe_ch_s0 = mysqli_query($conn, $ch_s0);
		//Set status to 1
		$run_f = mysqli_fetch_array($run);
		$ch_s1 = "UPDATE tbl_pg SET status='1' WHERE id='".$run_f['id']."'";
		$exe_ch_s1 = mysqli_query($conn, $ch_s1);
	}
?>

<?php include 'header.php'; ?>

      <div class="main-panel">
        <div class="content-wrapper">
          <div class="row">
            <div class="col-sm-12 mb-4 mb-xl-0"><h4>Update Withdraw Gateway</h4>
            </div>
          </div> 
		  <div class="row">			
          </div>
		  <div class="row">
            <?php
				$sel_upi = "SELECT * FROM tbl_pg WHERE status='0' OR status='1'";
				$upi_r = mysqli_query($conn, $sel_upi);
			?>
				<form action="#" id="upisave" method="post" autocomplete="off">
			<?php	while ($row = mysqli_fetch_array($upi_r)) {
			?>
				<input name="upiid" type="radio" style="margin-top: 10px; margin-left:12px;" value="<?php echo $row['value']; ?>" <?php if($row['status']==1){echo "checked";} ?> />
				<label for="<?php echo $row['value']; ?>"><?php echo $row['value']; ?></label>
				</br>
			<?php	}
			?>
				<button type="submit" class="btn btn-primary cool-button mr-2">Save</button>
				</form>
          </div>		  					  		  		  
        </div>
        <footer class="footer">
          <div class="d-sm-flex justify-content-center justify-content-sm-between">
            <span class="text-muted d-block text-center text-sm-left d-sm-inline-block">Copyright © 51gameplay.online 2024</span>
          </div>
        </footer>
      </div>
    </div>
  </div>
  <script>	
	if ( window.history.replaceState ) {
        window.history.replaceState( null, null, window.location.href );
    }
  </script>
</body>

</html>