<?php
 include("db.php");
  $get_id=$_GET['editID']; 
  $information_sql="select username from  `admin` where id='$get_id'";
  $information_query= $db->query($information_sql);
  $information_row=$information_query->fetch_array();
  $userName_retrive=$information_row['username'];
 
   
?> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
<html>
<head>
	<title>ویـرایـش رمــز عبـور</title>
 
	<link rel="stylesheet" type="text/css" href="../css/style.css">
   <script src="dist/sweetalert-dev.js"></script>
  <link rel="stylesheet" href="dist/sweetalert.css">  
</head>
<body>

	<div id="wrap">
		 
		<div id="contentt">
			 
			<div id="menu">
				<?php  //include("menu.php") ;   ?>
			</div>
		    <div id="matlab">
			<div id="title"><p>ویــرایــش نــام کـــاربــــری وتعـــریــف نحـــو فعـالیـت</p> </div>
			<div id="picture">
					<table border="0" width="400px">
						<tr>
							<td style="width:180px;"><img src="../img/user.png" width="150px" height="120px">  </td>
							<td ><h3> </h3></td>
						</tr>
					</table>
			   </div>
		    	<form method="post" action="">
               <table border="0" dir="rtl" id="rgistera_cart" width="800px">
		    		<tr>
						<td style="width:190px">&nbsp;</td>
		    			<th style="width:150px">نـام کـاربـری</th>
						<td style="width:180px"><input type="text" name="userName" value='<?php  echo $userName_retrive;   ?>'></td>
						<td style="width:350px;">
							 
						 </td>
		    		</tr>
					 
					<tr>
						<td style="width:190px">&nbsp;</td>
		    			<th style="width:150px">رمـز عبــور</th>
						<td style="width:180px"><input type="password" name="password"  ></td>
						<td style="width:350px;"></td>
		    		</tr> 
					 
		    	</table>
		    	<div id="submit"> 
					      <table border="0" dir="rtl" id="submit" align="center">
								<tr>

									<td>
									    <input type="submit" id="save"   name="save"  value="ذخیره">
							            <input type="submit" id="back"   name="back"  value="انصراف">
							
									</td>
								</tr>
						  </table>
					</div>
				</form>
		    </div>


		</div>
		 
	</div>
</body>
</html>
<?php
     
if($_POST['back']){
  header("location:../admin.php");
}
if($_POST['save']){
$userName_poor=$_POST['userName'];
$userName= strtolower($userName_poor);
  
$password=$_POST['password'];
 
 $newPassword=md5($password); 
      
	  
    
	   
	       $updateUserNamesql="update admin set username='$userName',password='$newPassword' where id='$get_id'";
	       $updateUserNamequery= $db ->query($updateUserNamesql);
	         echo' <script>
				  swal({
					title: "اطلاعات ثبت شد!",
					timer: 1200,
					showConfirmButton: false
				});
		        
			   window.close();	
				</script>'; 
	         echo '<meta http-equiv="refresh" content ="1; url=../index.php" >';
		die;
	       
}



?>