<?php

session_start();
include('includes/php/dbconnection.php');






 /////////////////change password//////////
if($_POST['chngpass']==2)
{

	
	foreach ($_POST as $k => $v )
	{
		$$k = addslashes($v);
	  $_SESSION['regtest'][$k] = $v;
	}
	$flg = false;
	//echo $currentpass; exit;
	
		/*echo $_SESSION['regtest']['testurl'];
		echo $_SESSION['regtest']['tasks'];
		
		echo $_SESSION['regtest']['tasks'];
		echo $_SESSION['regtest']['totaltesters'];
		
		echo $_SESSION['regtest']['gender'];
		echo $_SESSION['regtest']['age'];
		echo $_SESSION['regtest']['income'];
		echo $_SESSION['regtest']['internetskill'];*/
		
	
	if(!$currentpass)
	{
		$_SESSION['sesErr']['currentpass'] = '<img src="images/error.gif" border="0" width="14" height="14" style="cursor:pointer;" onmouseover="document.getElementById(\'currentpassdiv\').style.display=\'block\';" onmouseout="document.getElementById(\'currentpassdiv\').style.display=\'none\';" /><div id="currentpassdiv" style="display:none;"><span class="hint">Please enter your current password.<span class="hint-pointer">&nbsp;</span></span></div>';
		$flg = true;
	}
	if($currentpass)
	{        $csql="select * from tbl_admin where admin_id='31' AND admin_password='".$currentpass."' "; 
	         $result1 = mysql_query($csql);
			 $passrows = mysql_num_rows($result1);
			//echo $currentpass;
			//exit;
			// echo $passrows; exit;
			if($passrows == 0)
			{
			$_SESSION['sesErr']['currentpass'] = '<img src="images/error.gif" border="0" width="14" height="14" style="cursor:pointer;" onmouseover="document.getElementById(\'emaildiv\').style.display=\'block\';" onmouseout="document.getElementById(\'emaildiv\').style.display=\'none\';" /><div id="emaildiv" style="display:none;"><span class="hint">You entered invalid current password.<span class="hint-pointer">&nbsp;</span></span></div>';
			$flg = true;
		   }
		
	}
	
	if(!$newpass)
	{
		$_SESSION['sesErr']['newpass'] = '<img src="images/error.gif" border="0" width="14" height="14" style="cursor:pointer;" onmouseover="document.getElementById(\'passwdiv\').style.display=\'block\';" onmouseout="document.getElementById(\'passwdiv\').style.display=\'none\';" /><div id="passwdiv" style="display:none;"><span class="hint">Please enter new password.<span class="hint-pointer">&nbsp;</span></span></div>';
		$flg = true;
	}
	if($newpass != $cpass)
	{  //echo $newpass."---".$cpass;
	//exit;
		$_SESSION['sesErr']['cpass'] = '<img src="images/error.gif" border="0" width="14" height="14" style="cursor:pointer;" onmouseover="document.getElementById(\'cpassdiv\').style.display=\'block\';" onmouseout="document.getElementById(\'cpassdiv\').style.display=\'none\';" /><div id="cpassdiv" style="display:none;"><span class="hint">Your password and confirm password are not match with each other.<span class="hint-pointer">&nbsp;</span></span></div>';
		$flg = true;
	}
	
	if(!$flg)
	{
	$qry = "update tbl_admin set  
				admin_password = '".$newpass."'
				where admin_id ='31'";
		$result = @mysql_query($qry);
		if($result)
		{
			$_SESSION['msgpass'] = "Your Password Change Successfully";
			$_SESSION['activelink'] = "changepass";
			$_SESSION['qrystr'] = "signuptest";
		}
		
	}
	$p=$_SESSION['activelink'];
	header('location:settings.php');
	exit;

}?>

