<?php include("header.php");
if(!isset($_SESSION['cid']))
{
	?>
		<script>
        	window.location="<?php echo $actual_link?>index";
        </script>
	<?php
}

$msg="";
$sqlmydetail=mysql_query("select * from tbl_users where userid='".$_SESSION['cid']."'");
$resmydetail=mysql_fetch_assoc($sqlmydetail);


$fullname=$resmydetail['fullname'];

$explodename=explode(" ",$fullname);

$countname=count($explodename);


if(isset($_POST['update']))
{
	$password=md5($_POST['password']);
	
		$update=mysql_query("update tbl_users set password='".$password."' where userid='".$_SESSION['cid']."'");
	
		$msg="Password Update Successfully";
		
		
	
	?>
		<script>
		setTimeout(function(){
			window.location="<?php echo $actual_link;?>signout";
		},2000);
		</script>
	<?php 
}

?>
 
<div class="main-container">
<div class="container">
<?php 
if($msg!=="")
{
	?>
	<div class="alert alert-success">
      <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
      <?php echo $msg;?>
    </div>
	<?php
}
?>
<div class="row">
<?php include("profileside.php");?>
 
<div class="col-sm-9 page-content">
<div class="inner-box">
<div class="row">
<div class="col-md-5 col-xs-4 col-xxs-12">
<h3 class="no-padding text-center-480 useradmin"><a href="#"><img class="userImg" src="images/user.jpg" alt="user"> <?php echo $_SESSION['cname'];?> </a> </h3>
</div>
<div class="col-md-7 col-xs-8 col-xxs-12">
<div class="header-data text-center-xs">
 
<!--<div class="hdata">
<div class="mcol-left">
 
<i class="fa fa-eye ln-shadow"></i> </div>
<div class="mcol-right">
 
<p><a href="#">7000</a> <em>visits</em></p>
</div>
<div class="clearfix"></div>
</div>-->
 
<div class="hdata">
<div class="mcol-left">
 
<i class="icon-th-thumb ln-shadow"></i> </div>
<div class="mcol-right">
<?php $sqltotala=mysql_query("select * from tbl_ads where posted_userid='".$_SESSION['cid']."' and admin_status='Approved'");

?> 
<p><a href="<?php $actual_link?>myads"><?php echo mysql_num_rows($sqltotala);?></a><em>Ads</em></p>
</div>
<div class="clearfix"></div>
</div>
 
<div class="hdata">
<div class="mcol-left">
 
<i class="fa fa-user ln-shadow"></i> </div>
<div class="mcol-right">
 <?php 
$sql_fav_ads1=mysql_query("select * from tbl_favorite where userid='".$_SESSION['cid']."'");
//$num_fav=mysql_num_rows($sql_fav_ads1);
$kl=0;
while($resfavs=mysql_fetch_assoc($sql_fav_ads1))
{
$sqlads1=mysql_query("select * from tbl_ads where ads_id='".$resfavs['ads_id']."' and admin_status!='Achieved'");
$resads1=mysql_fetch_assoc($sqlads1);

if($resads1['ads_id']>0)
{
	$kl++;
}
}

?>
<p><a href="<?php $actual_link?>favourite_ads"><?php echo $kl;?></a> <em>Favorites </em></p>
</div>
<div class="clearfix"></div>
</div>
</div>
</div>
</div>
</div>
<div class="inner-box">
<div class="welcome-msg">
<h3 class="page-sub-header2 clearfix no-padding">Hello <?php echo $_SESSION['cname'];?> </h3>
 </div>
<div id="accordion" class="panel-group">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title"> <a href="#collapseB1" data-toggle="collapse"> Change Password  </a> </h4>
</div>
<div class="panel-collapse collapse in" id="collapseB1">
<div class="panel-body">
<form class="form-horizontal" role="form" method="post">
<div class="form-group">
<label class="col-sm-3 control-label">New Password</label>
<div class="col-sm-9">
<input type="password" name="password" class="form-control" value="">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Confirm Password</label>
<div class="col-sm-9">
<input type="password" name="confirm_password" class="form-control" value="">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-9">
<div id="matchP">
</div>
</div>
</div>





<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<button type="submit" name="update" class="btn btn-default">Save</button>
</div>
</div>
</form>
</div>
</div>
</div>

</div>
 
</div>
</div>
 
</div>
 
</div>
 
</div>
 
<?php include("footer.php");?>
<script>
$("input[name='confirm_password']").focusout(function(){

if($("input[name='confirm_password']").val()==$("input[name='password']").val())
{
	$("#matchP").html("<strong>Password Match<strong>");
	$("button[type='submit']").attr("disabled",false);
}
else
{
	$("#matchP").html("<strong>Password Does Not Match<strong>");
	$("button[type='submit']").attr("disabled",true);
	
}


});

$(document).ready(function(){
$("input[type='password']").bind("cut copy paste",function(e){
e.preventDefault();
});
});
</script>