<?php
session_start();
include_once('connect.php');

$sql= mysqli_query($con, "SELECT * FROM admin ");
$r = mysqli_fetch_array($sql);
$user = $r['username'];
$pass = $r['password'];

?><?php
if($_SERVER['REQUEST_METHOD']=='POST'){
//change admin login info.
$user = $_POST['user'];
$pass = $_POST['pass'];

$sql= mysqli_query($con, " UPDATE admin SET username = '$user', password= '$pass' ");
if($sql){
	session_destroy;
echo "<script type='text/javascript'>
		alert('successful');
		window.location='admin_login.html';
		</script>";
}else{
echo "<script type='text/javascript'>
		alert('failed to change');
		window.location='change.php';
		</script>";

}
}

?>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>NOBLECASH: ADMIN</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <style>
  .modal-header, h4, .close {
      background-color: #5cb85c;
      color:white !important;
      text-align: center;
      font-size: 30px;
  }
  .modal-footer {
      background-color: #f9f9f9;
  }
  body {
	background-color: #66FFFF;
}
.style2 {font-weight: bold}
  .style3 {
	color: #FFFFFF;
	font-weight: bold;
}
  .style4 {color: #0000FF}
.style6 {color: #9933CC}
  </style>
</head>

<body>
 <p align="center" class="style3 style4">&nbsp;</p>
 <p align="center" class="style3 style4">&nbsp;</p>
 <p align="center" class="style3 style4">&nbsp;</p>
 <p align="center" class="style3 style4">NOBLE CASH ADMIN LOGIN</p>
 <form action="change.php" method="post" enctype="multipart/form-data" name="form1">
   <table width="436" height="102" align="center" bordercolor="#3333FF">
     <tr>
       <td width="103" height="32"><div align="right" class="style3 style6">username</div></td>
       <td width="321"><div align="center">
         <input name="user" type="text" id="user" value="<?php echo $user; ?>" size="50">
       </div></td>
     </tr>
     <tr>
       <td height="32"><div align="right" class="style6">
         <p>&nbsp;</p>
         <p><strong>Password</strong></p>
       </div></td>
       <td><p>&nbsp;
         </p>
         <p align="center">
           <input name="pass" type="text" id="pass" value="<?php echo $pass; ?>" size="50">
         </p></td>
     </tr>
     <tr>
       <td height="34">&nbsp;</td>
       <td>
         <div align="center">
           <input type="submit" name="Submit" value="change">
         </div></td>
     </tr>
   </table>
   <p align="center">&nbsp;</p>
</form>
 <p align="center">&nbsp; </p>
 <div align="center" class="style2"></div>
</body>
</html>
