<?php

    
	require_once 'dbconfig.php';
	
	if(isset($_GET['delete_id']))
	{
		// select image from db to delete
		$stmt_select = $DB_con->prepare('SELECT userPic FROM tbl_users WHERE userID =:uid');
		$stmt_select->execute(array(':uid'=>$_GET['delete_id']));
		$imgRow=$stmt_select->fetch(PDO::FETCH_ASSOC);
		unlink("user_images/".$imgRow['userPic']);
		
		// it will delete an actual record from db
		$stmt_delete = $DB_con->prepare('DELETE FROM tbl_users WHERE userID =:uid');
		$stmt_delete->bindParam(':uid',$_GET['delete_id']);
		$stmt_delete->execute();
		
		header("Location: index.php");
	}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" />
<title>MasterKings.Ga | Thumbnails</title>
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="bootstrap/css/bootstrap-theme.min.css">
</head>

<body>

<div class="logo"><div class="rss"><a href="/"><img src="/theme/panahan/images/home.png" alt="logo MasterKings"></a></div><div class="text"><span style="color:skyblue"><i><b> MasterKings.Ga </b></i></span></div><div class="text2"><span style="color:skyblue"><i> Social Forum Development Bangladesh Community </i></span></div></div>

<div class="navbar navbar-default navbar-static-top" role="navigation">
    <div class="container">
 
        <div class="navbar-header">
            <a class="navbar-brand" href="/">Home</a>
            <a class="navbar-brand" href="/forum">Forum</a>
            <a class="navbar-brand" href="/guestbook">Guestbook</a>
            <a class="navbar-brand" href="/album">Album</a>
        </div>
 
    </div>
</div>




<div class="container">

	<div class="page-header">
    	<h1 class="h2"><a class="btn btn-default" href="addnew.php"> <span class="glyphicon glyphicon-plus"></span> &nbsp; Add New Thumbnail </a> | <a class="btn btn-default" href="javascript:history.back(1)"> back to previous page</a></h1> 
    </div>
    
<br />

<h1 class="h2">Last 5 Thumbnails Uploaded</h1>

<div class="row">
<?php
	
	$stmt = $DB_con->prepare('SELECT userID, userName, userProfession, userPic FROM tbl_users ORDER BY userID DESC LIMIT 5');
	$stmt->execute();
	
	if($stmt->rowCount() > 0)
	{
		while($row=$stmt->fetch(PDO::FETCH_ASSOC))
		{
			extract($row);
			?>
			
				<p class="page-header"><?php echo $userName."&nbsp;/&nbsp;".$userProfession; ?></p>
				<img src="user_images/<?php echo $row['userPic']; ?>" class="img-rounded" width="250px" height="250px" />
<b>Thumbnail url(Past It On Thumbnail Url Box):<br></b><input type="text" size="20" value="/thumbnails/user_images/<?php echo $row['userPic']; ?>"/><hr/>
				
			</div>       
			<?php
		}
	}
	else
	{
		?>
        <div class="col-xs-12">
        	<div class="alert alert-warning">
            	<span class="glyphicon glyphicon-info-sign"></span> &nbsp; No Data Found On Server please Contact <a href="http://fb.com/dearmanbinrahman">Administrator on facebook</a>...
            </div>
        </div>
        <?php
	}
	
?>
</div>	



<div class="alert alert-info">
    ©MasterKings.Ga | Thumbnails
</div>

</div>


<!-- Latest compiled and minified JavaScript -->
<script src="bootstrap/js/bootstrap.min.js"></script>


</body>
</html>