<?php 
include('dbconnect.php');
function getExtension($str) {
         $i = strrpos($str,".");
         if (!$i) { return ""; }
         $l = strlen($str) - $i;
         $ext = substr($str,$i+1,$l);
         return $ext;
 }
if(isset($_GET['Upload'])){
    $userid=$_GET['Upload'];
    }
	if(isset($_POST['Upload'])){
		$change=array();
		$containing_dir = "upload";
		$filename=$_FILES['imgfile']['name'];
		$tempFile=$_FILES["imgfile"]["tmp_name"];
		$fileup=$containing_dir."/".$filename;
		
		$filename = stripslashes($filename);
  		$extension = getExtension($filename);
		$extension = strtolower($extension);
 if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")){
 			$change[]='Unknown Image extension ';
return false;
 		}
		if(empty($change)){
	// file needs to be jpg,gif,bmp,x-png and 4 MB max
	if(move_uploaded_file($tempFile,$fileup)){
		$filename=$_FILES["imgfile"]["name"];
			$updatepass="UPDATE cleintuser SET Picture='$filename' where user_id='$userid'";

	mysql_query($updatepass) or die(mysql_error());

		$change[]="Upload Sucessfull \n".$_FILES["imgfile"]["name"];
		}
	}

	else{
		$change[]="Error!:make sure the file is jpg, gif or png and that is smaller than 4MB";

	}
	$changes=implode('<br />',$change);


	}

             if(isset($_GET['Deleteit']) && isset($_GET['UpdateTran'])){  
 $del= $_GET["Deleteit"];
 $UpdateTran= $_GET["UpdateTran"];
 
$sql = "DELETE FROM TransactionHistory WHERE id='$del' ";

 mysql_query($sql) or die (mysql_error());
 
 header('location: Administrator?UpdateTran='.$UpdateTran);
}
	
  if(isset($_GET['?logoff.php']))
              {
				  session_destroy();
			  }
if(isset($_GET['Delete'])){
 $del= $_GET["Delete"];

$sql = "DELETE FROM  cleintuser WHERE user_id='$del'";

 mysql_query($sql) or die (mysql_error());
}
if(isset($_POST['LoginAdmin']))
{
	// Checking whether the Login form has been submitted

	$err = array();
	// Will hold our errors


	if(!$_POST['Pin'])
		$err[] = 'All the fields must be filled in!';

	if(!count($err))
	{
		$pass= $_POST['Pin'];



		// Escaping all input data'".$user."'

		$row = mysql_fetch_assoc(mysql_query("SELECT * FROM admin WHERE adminpin='$pass'"));

	if($row['adminpin'])
		{

			// If everything is OK login
			$username=$row['adminpin '];

			$_SESSION['UserAdmin']="$username";
			header("location:Administrator.php?ViewUser=Admin");
    	}
		else $err[]='Wrong username and/or password!  ';

	}


	if($err)
	$loginerrror = implode('<br />',$err);
	// Save the error messages in the session

	}

?>
<!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" />
<title>Welcome Administrator</title>
<style type="text/css">
<!--
body { font-family:Georgia, "Times New Roman", Times, serif;
}
-->
</style></head>

<body><center>

<?php  if(!isset($_SESSION['UserAdmin'])):?>

<form name="Login" action="?Login" method="post">
  <p><strong>Admin Login
    </strong></p>
    <?php if(isset($loginerrror)){ echo "<div style='background:#FFEDD2; border:#c00 1px solid; width:250px; padding:10px;'>$loginerrror</div>"; } ?><br  />
  Admin Pin:
  <input name="Pin" type="password" /><br />
  <input name="LoginAdmin" type="submit" value="Login" />
</form><?php  elseif((isset($_SESSION['UserAdmin'])) && !isset($_GET['ViewUser']) && !isset($_GET['FullDetails']) && !isset($_GET['EditUser'])&& !isset($_GET['UpdateTran'])&& !isset($_GET['Message'])&& !isset($_GET['AddUser'])&& !isset($_GET['Upload'])&& !isset($_GET['AllUsers'])):?>
<script type="text/javascript">
<!--
window.location = "?ViewUser=Admin"
//-->
</script>
    <?php  elseif((isset($_SESSION['UserAdmin'])) && isset($_GET['ViewUser']) && !isset($_GET['FullDetails']) && !isset($_GET['EditUser'])&& !isset($_GET['UpdateTran'])&& !isset($_GET['Message'])&& !isset($_GET['AddUser'])&& !isset($_GET['Upload'])&& !isset($_GET['AllUsers'])):?>
  </p> <strong>View all User</strong><br /><br />

<table width="696" height="52" border="1" align="center">
    <tr>
      <td width="20" height="24"><strong>id</strong></td>
      <td width="106">username</td>
      <td width="81">Pin</td>
      <td width="88">Names</td>
      <td width="81">&nbsp;</td>
      <td width="60">&nbsp;</td>
      <td width="53">&nbsp;</td>
      <td width="71">&nbsp;</td>
      <td width="78">&nbsp;</td>
<td width="78">&nbsp;</td>
    </tr>
   <?php $getdata="SELECT * from cleintuser  order by user_id DESC";
   $query=mysql_query($getdata) or die (mysql_error());
	while($datas=mysql_fetch_array($query)){
		$user_id=$datas['user_id'];
    print "<tr>
      <td>$datas[user_id]</td>
      <td>$datas[Username]</td>
      <td>$datas[Pin]</td>
      <td>$datas[FullName]</td>
      <td><a href='?FullDetails=$datas[user_id]'>View</a></td>
      <td><a href='?EditUser=$datas[user_id]'>Edit</a></td>
      <td><a href='?Delete=$datas[user_id]'>Delete</a></td>
       <td><a href='?UpdateTran=$datas[user_id]'>Add Tran</a></td>
      <td><a href='?Message=$datas[user_id]'>Message</a></td>
 <td><a href='?Upload=$datas[user_id]'>Upload Picture</a></td>
    </tr> ";} ?>
  </table>

  <p><a href="?AddUser=Newuser">Create New Account</a> | <a href="?Upload=<?php echo "$user_id"; ?>">Upload Picture </a>| <a href="?AllUsers">View Registered Users</a> | <a href="ccb_login">Log Out</a>

</p>
<p style="color:red;"><strong>NEED HELP? TRY LINKS BELOW</strong></p>
<SCRIPT TYPE="text/javascript">
<!--
function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=650,height=400,scrollbars=yes');
return false;
}
//-->
</SCRIPT>

<p ><a href="Help/helpcreateacc.html" onClick="return popup(this, 'stevie')">Click Here to Learn How to Create Account</a></p>

<p><a href="Help/helpedit.html" onClick="return popup(this, 'stevie')">Click Here to Learn How to Edit Account</a> </p>
<p><a href="Help/helpupload.html" onClick="return popup(this, 'stevie')">Click Here to Learn How to upload Picture</a> </p>
<p><a href="Help/addtrans.html" onClick="return popup(this, 'stevie')">Click Here to Learn How to Add Transactions</a> </p>
<p><a href="Help/admesshelp.html" onClick="return popup(this, 'stevie')">Click Here to Learn How to Add Message</a> </p>

</p>  <?php  elseif((isset($_SESSION['UserAdmin'])) && !isset($_GET['ViewUser']) && isset($_GET['FullDetails']) && !isset($_GET['EditUser'])&& !isset($_GET['UpdateTran'])&& !isset($_GET['Message'])&& !isset($_GET['AddUser'])&& !isset($_GET['Upload'])&& !isset($_GET['AllUsers'])):?>
 <p>Full Details</p>
 <table border="1" width="354">
    <tbody> <?php
 if(isset($_GET['FullDetails'])){
    $userid=$_GET['FullDetails'];
    }
 $getdata="SELECT * from cleintuser where user_id=$userid";
   $query=mysql_query($getdata) or die (mysql_error());
	while($datas=mysql_fetch_array($query)){
?>
      <tr>
        <td width='147'>ID</td>
        <td width='191'><?php echo $datas['user_id'];?></td>
      </tr>
      <tr>
        <td>Username</td>
        <td><?php echo $datas['Username'];?></td>
      </tr>
      <tr>
        <td>Pin</td>
        <td><?php echo $datas['Pin'];?></td>
      </tr>
      <tr>
        <td>Account Number </td>
        <td><?php echo $datas['AccountNumber'];?></td>
      </tr>
      <tr>
        <td>Names</td>
        <td><?php echo $datas['FullName'];?></td>
      </tr>
      <tr>
        <td>Email</td>
        <td><?php echo $datas['email'];?></td>
      </tr>
      <tr>
        <td>Address</td>
        <td><?php echo $datas['Address'];?></td>
      </tr>
      <tr>
        <td>Account Type </td>
        <td><?php echo $datas['Accounttype'];?></td>
      </tr>
      <tr>
        <td>Currency</td>
        <td><?php echo $datas['Currency'];?></td>
      </tr>
      <tr>
        <td>Opening Balance </td>
        <td><?php echo $datas['Openingbalance'];?></td>
      </tr>
      <tr>
        <td>Date Deposited </td>
        <td><?php echo $datas['Datedeposited'];?></td>
      </tr>
      <tr>
        <td>Total Amount </td>
        <td><?php echo $datas['Totalamt'];?></td>
      </tr>
      <tr bgcolor='#66ccff'>
        <td colspan='2'><div align='center'><strong>These are the Codes </strong></div></td>
      </tr>
      <tr>
        <td>TAX Code </td>
        <td><?php echo $datas['COTCode'];?></td>
      </tr>
      <tr>
        <td>ITC Code</td>
        <td><?php echo $datas['ActivationCode'];?></td>
      </tr>
      <tr>
        <td>IMF Code:</td>
        <td><?php echo $datas['EECCode'];?></td>
      </tr>
      <tr>
        <td>COT Code</td>
        <td><?php echo $datas['TaxCode'];?></td>
      </tr>
      <tr bgcolor='#66ccff'>
        <td colspan='2'><div align='center'><strong>These are the transaction </strong></div></td>
      </tr>
      <tr>
        <td>Date 1 </td>
        <td><?php echo $datas['Date1'];?></td>
      </tr>
      <tr>
        <td>Time 1 </td>
        <td><?php echo $datas['Time1'];?></td>
      </tr>
      <tr>
        <td>Credit 1 </td>
        <td><?php echo $datas['Credit1'];?></td>
      </tr>
      <tr>
        <td>Debit 1 </td>
        <td><?php echo $datas['Debit1'];?></td>
      </tr>
      <tr>
        <td>Transaction Details 1 </td>
        <td><?php echo $datas['TransactionDetails1'];?></td>
      </tr>
      <tr>
        <td>Date 2 </td>
        <td><?php echo $datas['Date2'];?></td>
      </tr>
      <tr>
        <td>Time 2 </td>
        <td><?php echo $datas['Time2'];?></td>
      </tr>
      <tr>
        <td>Credit 2 </td>
        <td><?php echo $datas['Credit2'];?></td>
      </tr>
      <tr>
        <td>Debit 2 </td>
        <td><?php echo $datas['Debit2'];?></td>
      </tr>
      <tr>
        <td>Transaction Details 2 </td>
        <td><?php echo $datas['TransactionDetails2'];?></td>
      </tr>
      <tr>
        <td>Date 3 </td>
        <td><?php echo $datas['Date3'];?></td>
      </tr>
      <tr>
        <td>Time 3 </td>
        <td><?php echo $datas['Time3'];?></td>
      </tr>
      <tr>
        <td>Credit 3 </td>
        <td><?php echo $datas['Credit3'];?></td>
      </tr>
      <tr>
        <td>Debit 3 </td>
        <td><?php echo $datas['Debit3'];?></td>
      </tr>
      <tr>
        <td>Transaction Details 3 </td>
        <td><?php echo $datas['TransactionDetails3'];?></td>
      </tr>
      <tr>
        <td>Date 4 </td>
        <td><?php echo $datas['Date4'];?></td>
      </tr>
      <tr>
        <td>Time 4 </td>
        <td><?php echo $datas['Time4'];?></td>
      </tr>
      <tr>
        <td>Credit 4 </td>
        <td><?php echo $datas['Credit4'];?></td>
      </tr>
      <tr>
        <td>Debit 4 </td>
        <td><?php echo $datas['Debit4'];?></td>
      </tr>
      <tr>
        <td>Transaction Details 4 </td>
        <td><?php echo $datas['TransactionDetails4'];?></td>
      </tr>
      <tr bgcolor='#ffffff'>
        <td colspan='2'><div align='center'>Bank Transfer Details </div></td>
      </tr>
      <tr>
        <td>Bank Name </td>
        <td><?php echo $datas['BankName'];?></td>
      </tr>
      <tr>
        <td>Bank Branch </td>
        <td><?php echo $datas['BankBranch'];?></td>
      </tr>
      <tr>
        <td>Bank City </td>
        <td><?php echo $datas['BankCity'];?></td>
      </tr>
      <tr>
        <td>Bank Swift</td>
        <td><?php echo $datas['BankSwift'];?></td>
      </tr>
      <tr>
        <td>Account Holder </td>
        <td><?php echo $datas['AccountHolder'];?></td>
      </tr>
      <tr>
        <td>Destination Account </td>
        <td><?php echo $datas['DestinationAccount'];?></td>
      </tr>
      <tr>
        <td>Currency</td>
        <td><?php echo $datas['CurrencyT'];?></td>
      </tr>
      <tr>
        <td>Amount</td>
        <td><?php echo $datas['Amount'];?></td>
      </tr>
<?php
	} ?></tbody>
  </table>
  <p><a href="?ViewUser=Admin">Back</a></p>
    <p>
  <?php  elseif((isset($_SESSION['UserAdmin'])) && !isset($_GET['ViewUser']) && !isset($_GET['FullDetails']) && isset($_GET['EditUser'])&& !isset($_GET['UpdateTran'])&& !isset($_GET['Message'])&& !isset($_GET['AddUser'])&& !isset($_GET['Upload'])&& !isset($_GET['AllUsers'])):?>
  </p>
    <p>Edit Users </p>
     <form id="form1" name="form1" method="post" action="">
  <table width="339" border="0">
    <?php
    if(isset($_GET['EditUser'])){
    $userid=$_GET['EditUser'];
    }
	if(isset($_POST['Update'])){
	 $username= $_POST['Username'];
  $pin= $_POST['Pin'];
    $accountnos= $_POST['AccountNumber'];
	  $names= $_POST['FullName'];
	  $email= $_POST['email'];
	    $address= $_POST['Address'];
		  $accounttype= $_POST['Accounttype'];
		    $curren= $_POST['Currency'];  $openingbalance= $_POST['Openingbalance'];
			  $datedeposited= $_POST['Datedeposited'];
			   				  $totalamt= $_POST['Totalamt'];
	  $cotcode= $_POST['COTCode']; $Tax= $_POST['TaxCode']; $activation= $_POST['ActivationCode']; $eec=$_POST['EECCode'];
	  
	  $Nationality= $_POST['Nationality']; $State= $_POST['State']; $ZipCode= $_POST['ZipCode']; $tellM=$_POST['tellM']; $tellW= $_POST['tellW']; $tellH=$_POST['tellH'];
	  
	  
	   $update="UPDATE cleintuser SET Username='$username',Pin='$pin', tellM='$tellM', tellW='$tellW', tellH='$tellH', AccountNumber='$accountnos',FullName='$names',  Nationality='$Nationality', State='$State', ZipCode='$ZipCode', email='$email',Address='$address',Accounttype='$accounttype',Currency='$curren',Openingbalance='$openingbalance',Datedeposited='$datedeposited',Totalamt='$totalamt',COTCode='$cotcode',TaxCode='$Tax',ActivationCode='$activation',EECCode='$eec' where user_id='$userid'";

	mysql_query($update) or die(mysql_error());
	}

     $getdata="SELECT * from cleintuser  where user_id='$userid'";
   $query=mysql_query($getdata) or die (mysql_error());
	while($datas=mysql_fetch_array($query)){

 ?>
    <tr>
      <td width='134'>Username:</td>
      <td width='189'><input type='text' name='Username' id='textfield' value='<?php echo $datas['Username']; ?>' /></td>
    </tr>
    <tr>
      <td>Pin:</td>
      <td><input type='text' name='Pin' id='textfield2' value='<?php echo $datas['Pin'];?>' /></td>
    </tr>
    <tr>
      <td>Account Number:</td>
      <td><input type='text' name='AccountNumber' id='textfield3' value='<?php echo $datas['AccountNumber'];?>' /></td>
    </tr>
    <tr>
      <td>Names:</td>
      <td><input type='text' name='FullName' id='textfield4'  value='<?php echo $datas['FullName'];?>'/></td>
    </tr>
    <tr>
      <td>Email:</td>
      <td><input type='text' name='email' id='textfield4'  value='<?php echo $datas['email'];?>'/></td>
    </tr>
    <tr>
      <td>Address:</td>
      <td><input type='text' name='Address' id='textfield5'  value='<?php echo $datas['Address'];?>' /></td>
    </tr>
    <tr>
      <td>Accounttype:</td>
      <td><input type='text' name='Accounttype' id='textfield6'   value='<?php echo $datas['Accounttype'];?>' /></td>
    </tr>
    <tr>
      <td>Curren:</td>
      <td><input type='text' name='Currency' id='textfield7' value='<?php echo $datas['Currency'];?>' /></td>
    </tr>
    <tr>
      <td>Openingbalance:</td>
      <td><input type='text' name='Openingbalance' id='textfield8' value='<?php echo $datas['Openingbalance'];?>' /></td>
    </tr>
    <tr>
      <td>Datedeposited:</td>
      <td><input type='text' name='Datedeposited' id='textfield9' value='<?php echo $datas['Datedeposited']; ?>' /></td>
    </tr>
    <tr>
      <td>Totalamt:</td>
      <td><input type='text' name='Totalamt' id='textfield15' value='<?php echo $datas['Totalamt'];?>'  /></td>
    </tr>
    
    
    <tr>
      <td>Nationality:</td>
      <td><input type='text' name='Nationality' id='textfield15' value='<?php echo $datas['Nationality'];?>'  /></td>
    </tr>
    <tr>
      <td>State:</td>
      <td><input type='text' name='State' id='textfield15' value='<?php echo $datas['State'];?>'  /></td>
    </tr>
    <tr>
      <td>ZipCode:</td>
      <td><input type='text' name='ZipCode' id='textfield15' value='<?php echo $datas['ZipCode'];?>'  /></td>
    </tr>
    <tr>
      <td>Mobile Tell:</td>
      <td><input type='text' name='tellM' id='textfield15' value='<?php echo $datas['tellM'];?>'  /></td>
    </tr>
    <tr>
      <td>Work Tell:</td>
      <td><input type='text' name='tellW' id='textfield15' value='<?php echo $datas['tellW'];?>'  /></td>
    </tr>
    
        <tr>
      <td>Home Tell:</td>
      <td><input type='text' name='tellH' id='textfield15' value='<?php echo $datas['tellH'];?>'  /></td>
    </tr>
    
    
    <tr>
      <td>Picture:</td>
      <td><img src='upload/<?php echo $datas['Picture'];?>' width="150" /></td>
    </tr>
    <tr>
      <td>TAX Code:</td>
      <td><input type='text' name='COTCode' id='textfield14' value='<?php echo $datas['COTCode'];?>'  /></td>
    </tr>
    <tr>
      <td>ITC Code:</td>
      <td><input type='text' name='ActivationCode' id='textfield12'  value='<?php echo $datas['ActivationCode'];?>' /></td>
    </tr>
    <tr>
      <td>IMF Code:</td>
      <td><input type='text' name='EECCode' id='textfield10'  value='<?php echo $datas['EECCode'];?>' /></td>
    </tr>
    <tr>
      <td>COT Code:</td>
      <td><input type='text' name='TaxCode' id='textfield11' value='<?php echo $datas['TaxCode'];?>' /></td>
    </tr>
       <tr>
      <td></td>
      <td><input type='submit' name='Update' id='textfield11' value='Update Record' /></td>
    </tr>
 <?php }?>
  </table>
</form>
<p><a href="?ViewUser=Admin">Go Back</a></p>
  <p>
    <?php  elseif((isset($_SESSION['UserAdmin'])) && !isset($_GET['ViewUser']) && !isset($_GET['FullDetails']) && !isset($_GET['EditUser'])&& isset($_GET['UpdateTran'])&& !isset($_GET['Message'])&& !isset($_GET['AddUser'])&& !isset($_GET['Upload'])&& !isset($_GET['AllUsers'])):?>
  </p>
  


       <?php
    if(isset($_GET['UpdateTran'])){
    $userid=$_GET['UpdateTran'];
    }

	if(isset($_POST['Recored'])){
	$Date = $_POST['Date']; $Time = $_POST['Time'];  $Credit = $_POST['Credit']; $Debit = $_POST['Debit'];   $TransactionDetails = $_POST['TransactionDetails']; 
 $insert="INSERT INTO TransactionHistory(user_id,TransactionDetails,Date,Time,Debit,Credit)
			 VALUES('$userid','$TransactionDetails','$Date','$Time','$Debit','$Credit')";
			 mysql_query($insert) or die(mysql_error());
	}
	
	?>

  <p>Update Account Transactions </p>
    <form action="" method="post" name="form1" id="form1">
    <table align="center">
      <tbody>
      
      <tr valign='baseline'>
          <td nowrap='nowrap' align='right'>Date:</td>
          <td><input type='text' name='Date'  /></td>
        </tr>
        <tr valign='baseline'>
          <td nowrap='nowrap' align='right'>Time1:</td>
          <td><input type='text' name='Time'  /></td>
        </tr>
        <tr valign='baseline'>
          <td nowrap='nowrap' align='right'>Credit1:</td>
          <td><input type='text' name='Credit'  /></td>
        </tr>
        <tr valign='baseline'>
          <td nowrap='nowrap' align='right'>Debit1:</td>
          <td><input type='text' name='Debit' /></td>
        </tr>
        <tr valign='baseline'>
          <td nowrap='nowrap' align='right'>Transaction Status 1:</td>
          <td><input type='text'  name='TransactionDetails' /></td>
        </tr>
         <tr valign='baseline'>
          <td nowrap='nowrap' align='right'></td>
          <td><input value='Update record' type='submit' name='Recored' /></td>
        </tr>
		      </tbody>
    </table>
  </form>
      
<br>

	<table align="center"  border="1">
      <tbody>	

<tr valign='baseline'>
            <td align='center'>S/N:</td>
          <td align='center'>Date:</td>
          <td align='center'>Time:</td>
		   <td align='center'>Credit:</td>
          <td align='center'>Debit:</td>
		   <td align='center'>Transaction:</td>
          <td align='center'>Action</td>
        </tr>
<?php
$s= 1 ;
     $getdata="SELECT * from TransactionHistory  where user_id='$userid'";
   $query=mysql_query($getdata) or die (mysql_error());
	while($datas=mysql_fetch_array($query)){
	    
	    
print"

<tr valign='baseline'>
            <td align='center'>".$s++."</td>
		   <td align='center'>".$datas[Date]."</td>
          <td align='center'>".$datas[Time]."</td>
		   <td align='center'>".$datas[Credit]."</td>
          <td align='center'>".$datas[Debit]."</td>
		   <td align='center'>".$datas[TransactionDetails]."</td>
          <td align='center'><a href='Administrator?UpdateTran=".$userid."&Deleteit=".$datas[id]."'>Delete</a></td>
        </tr>

"; } ?>


				 </tbody>
    </table>

    
      <p><a href="?ViewUser=Admin">Go Back</a></p>
      
     
  <p>
    <?php  elseif((isset($_SESSION['UserAdmin'])) && !isset($_GET['ViewUser']) && !isset($_GET['FullDetails']) && !isset($_GET['EditUser'])&& !isset($_GET['UpdateTran'])&& isset($_GET['Message'])&& !isset($_GET['AddUser'])&& !isset($_GET['Upload'])&& !isset($_GET['AllUsers'])):?>
  </p>
  <p>  Message
  </p>
  <?php
    if(isset($_GET['Message'])){
    $userid=$_GET['Message'];
    }
	if(isset($_POST['Message'])){
	$messages=$_POST['messages'];
	if(empty($messages)){
		$error=1;
		echo "<div style='background:#FFEDD2; border:#c00 1px solid; width:250px; padding:10px;'>You can not send empty message</div>";
	}
	if(empty($error)){
		if(isset($_GET['Message'])){
			$userid=$_GET['Message'];
		}
		  $insert="INSERT INTO message(message,user_id)
			 VALUES('$messages','$userid')";
			 mysql_query($insert) or die(mysql_error());

			$row = mysql_fetch_assoc(mysql_query("SELECT * FROM cleintuser WHERE user_id='$userid'"));

	if($row['messaagenum'])
		{
			$count=$row['messaagenum']+1;
		}
			 $up="UPDATE cleintuser SET messaagenum='$count' where user_id='$userid'";
			  mysql_query($up) or die(mysql_error());

			 echo "Message Sent";
	}

	}
	?>
  <form action="" method="post" name="form1" id="form1">
    <table align="center">
      <tbody>
        <tr valign="baseline">
          <td valign="top" nowrap="nowrap" align="right">Messages:</td>
          <td><textarea wrap="virtual" rows="8" cols="80" name="messages"></textarea></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right"></td>
          <td><input value="Send Message" type="submit" name="Message" /></td>
        </tr>
      </tbody>
        </table>

</form>
  <p>When you get to the end of a line where you want to press ENTER,   just type in this: &lt;br&gt; </p>
  <p><a href="?ViewUser=Admin">Go Back</a></p>
  <p><br />
    <?php  elseif((isset($_SESSION['UserAdmin'])) && !isset($_GET['ViewUser']) && !isset($_GET['FullDetails']) && !isset($_GET['EditUser'])&& !isset($_GET['UpdateTran'])&& !isset($_GET['Message'])&& isset($_GET['AddUser'])&& !isset($_GET['Upload'])&& !isset($_GET['AllUsers'])):?>
  </p>
  <p>Add New User </p>
  <?php
  if(isset($_POST['AddNew'])){
	 $username= $_POST['username'];
  $pin= $_POST['pin'];
    $accountnos= $_POST['accountnos'];
	  $names= $_POST['names'];
	  $email= $_POST['email'];
	    $address= $_POST['address'];
		  $accounttype= $_POST['accounttype'];
		    $curren= $_POST['curren'];  $openingbalance= $_POST['openingbalance'];
			  $datedeposited= $_POST['datedeposited'];
			   				  $totalamt= $_POST['totalamt'];
    $picture= $_POST['picture'];
	  $cotcode= $_POST['cotcode']; $Tax= $_POST['Tax']; $activation= $_POST['activation']; $eec=$_POST['eec'];
  $Nationality= $_POST['Nationality']; $State= $_POST['State']; $ZipCode= $_POST['ZipCode']; $tellM=$_POST['tellM']; $tellW= $_POST['tellW']; $tellH=$_POST['tellH'];
	  
	  if(empty($username)|| empty($pin)|| empty($accountnos)|| empty($names) ||empty($email) || empty($address)|| empty($accounttype)|| empty($curren)|| empty($openingbalance)|| empty($datedeposited)|| empty($totalamt)|| empty($picture)|| empty($cotcode)|| empty($Tax)|| empty($activation)|| empty($eec)){
		  $error=1;
		  echo"All Fiels Must be filled";
	  }
	  if(empty($error)){
			    $insert="INSERT INTO cleintuser(Username,Pin,AccountNumber,FullName,email,Address,Accounttype,Currency,Openingbalance,
			 Datedeposited,Totalamt,Picture,COTCode,ActivationCode,EECCode,TaxCode,Nationality,State,ZipCode,tellM,tellW,tellH)
			 VALUES('$username','$pin','$accountnos','$names','$email','$address','$accounttype','$curren','$openingbalance','$datedeposited','$totalamt',
			 '$picture','$cotcode','$activation','$eec','$Tax','$Nationality','$State','$ZipCode','$tellM','$tellW','$tellH')";
			 mysql_query($insert) or die(mysql_error());

			 echo "User added successful";
			   }

  } ?>
  <form action="" method="post" name="form1" id="form1">
    <table width="355" align="center">
      <tbody>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Username:</td>
          <td><input size="32" name="username" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Pin:</td>
          <td><input size="32" name="pin" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Accountnos:</td>
          <td><input size="32" name="accountnos" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Names:</td>
          <td><input size="32" name="names" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Email:</td>
          <td><input size="32" name="email" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Address:</td>
          <td><input size="32" name="address" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Accounttype:</td>
          <td><input size="32" name="accounttype" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Curren:</td>
          <td><input size="32" name="curren" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Openingbalance:</td>
          <td><input size="32" name="openingbalance" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Datedeposited:</td>
          <td><input size="32" name="datedeposited" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Totalamt:</td>
          <td><input size="32" name="totalamt" /></td>
        </tr>
        
        
        
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Nationality:</td>
          <td><input size="32" name="Nationality" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">State:</td>
          <td><input size="32" name="State" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">ZipCode:</td>
          <td><input size="32" name="ZipCode" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">tellM:</td>
          <td><input size="32" name="tellM" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">tellW:</td>
          <td><input size="32" name="tellW" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">tellH:</td>
          <td><input size="32" name="tellH" /></td>
        </tr>
        

        <tr valign="baseline">

          <td nowrap="nowrap" align="right">Picture:</td>
          <td><input value="images/unavailable.jpg" size="32" name="picture" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">TAX Code:</td>
          <td><input value="CU7362uiYq44589" size="32" name="cotcode" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">COT Code :</td>
          <td><input value="TU78832woYq445" size="32" name="Tax" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">IMF Code  :</td>
          <td><input value="XU736223bwq89" size="32" name="eec" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">ITC Code:</td>
          <td><input value="HETYYEW623478211" size="32" name="activation" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right"></td>
          <td><input value="Insert record" type="submit" name="AddNew" /></td>
        </tr>
      </tbody>
    </table>
  </form>
  <p>&nbsp;</p>
<p><a href="?ViewUser=Admin">Go Back</a></p>
  <p><?php  elseif((isset($_SESSION['UserAdmin'])) && !isset($_GET['ViewUser']) && !isset($_GET['FullDetails']) && !isset($_GET['EditUser'])&& !isset($_GET['UpdateTran'])&& !isset($_GET['Message'])&& !isset($_GET['AddUser'])&& isset($_GET['Upload'])&& !isset($_GET['AllUsers'])):?></p>
  <p align="left">Upload File</p>
    
 <?php   if(isset($changes)){ echo"<div style='background:#00FF00; border:#009933; 1px solid; width:450px; padding:10px;'>$changes</div>"; } ?>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
            <tbody>
              <tr>
                <td width="458">
                  <div></div></td>
              </tr>
              <tr>
                <td bgcolor="#ffffff"><p align="left">Upload a client's picture via the form below. Then copy the name   of the file with the extension... e.g. <em><strong>patruckig.jpg or   henleyrj.gif</strong></em>..... and then put it in the <strong>picture</strong> field in the Client Account you created. This is the picture that will be   displayed in the client's account.</p></td>
              </tr>
              <tr>
                <td bgcolor="#d2d2d2" height="40" valign="center" align="middle"><p>&nbsp; </p>
                  <form id="uploadImage" enctype="multipart/form-data" method="post" name="uploadImage" action="">
                    <p>
                       <label for="image">Upload   image:</label>
                      <input id="image" type="file" name="imgfile" />
                    </p>
                    <p>
                      <input id="upload" value="Upload" type="submit" name="Upload" />
                    </p>
                  </form>
                </td>
              </tr>
              <tr>
                <td valign="top" align="left"><table border="0" cellspacing="0" cellpadding="0" width="100%">
                  <tbody>
                    <tr>
                      <td valign="top" width="100%" align="right"><form>

                      </form>
                      </td>
                    </tr>
                  </tbody>
                </table></td>
              </tr>
              <tr>
                <td id="pay_btm">&nbsp;</td>
              </tr>
            </tbody>
  </table><a href="?ViewUser=Admin">Back View Users</a> <br /><?php  elseif((isset($_SESSION['UserAdmin'])) && !isset($_GET['ViewUser']) && !isset($_GET['FullDetails']) && !isset($_GET['EditUser'])&& !isset($_GET['UpdateTran'])&& !isset($_GET['Message'])&& !isset($_GET['AddUser'])&& !isset($_GET['Upload'])&& isset($_GET['AllUsers'])):?>

            <p><strong>All Registration Details </strong></p>

<table border="1">
  <tbody>
    <tr>
      <td>id</td>
      <td>First_Name</td>
      <td>Surname</td>
      <td>Gender</td>
      <td>Date_of_Birth</td>
      <td>Name_of_Company</td>
      <td>Contact_Address</td>
      <td>Home_Phone_Number</td>
      <td>Office_Phone_Number</td>
      <td>Mobile_Phone_Number</td>
      <td>Email_Address</td>
      <td>Nationality</td>
      <td>State</td>
      <td>Zip_Code</td>
      <td>Account_Currency</td>
      <td>Account_Type</td>
      <td>Set_Up_Fee</td>
      <td>Account_Password</td>
      <td>Confirm_Password</td>
      <td>Other_Bank_NameOther_Bank_Name</td>
      <td>Other_Bank_Address</td>
      <td>Other_Bank_Account_Name</td>
      <td>Other_Bank_Account_Number</td>
      <td>Other_Bank_Account_Routing_NumberSort_Code</td>
      <td>Next_Of_Kin</td>
      <td>Address_of_Next_Of_Kin</td>
      <td></td>
    </tr>
  </tbody>
</table>
<p align="center"><a href="?ViewUser=Admin">Back View Users</a> | <a href="?AddUser=Newuser">Create New Account</a> | <a href="?logoff">Log Out</a></p>
<?php else:
	endif;?>
</center>
</body>
</html>
