<?php

if (isset ( $_POST ['submit'] ) && $_POST ['check'] == 'register') {
	// echo "bhangi";
	$register = $_POST ['register'];
	
	$name = $register ['name'];
	$email1 = $register ['email1'];
	
	$contact = $register ['contact'];
	$address = $register ['address'];
	
	$paymentdetails = $register ['paymentdetails'];
	$newpayments = $register ['newpayments'];
	$mostawarded = $register ['mostawarded'];
	$earlierawards = $register ['earlierawards'];
	$giveanawards = $register ['giveanawards'];
	$employeesdetails = $register ['employeesdetails'];
	$newemployees = $register ['newemployees'];
	$clientdetails = $register ['clientdetails'];
	$newclient = $register ['newclient'];
	$departments = $register ['departments'];
	$newdepartments = $register ['newdepartments'];
	$addinventory = $register['addinventory'];
	$viewinventory = $register['viewinventory'];
	$addlocation = $register['addlocation'];
	$viewlocation = $register['viewlocation'];
	$type= $register['type'];
	$checkmail = $db->exists ( 'users', array ('email' => $email1 ) );
	
	if ($checkmail) {
		?>
<div class="hide1">
	<div id="gritter-notice-wrapper">
		<div id="gritter-item-2" class="gritter-item-wrapper gritter-warning"
			style="">
			<div class="gritter-top"></div>
			<div class="gritter-item">
				<div class="gritter-close" id="gritterremove"
					style="display: inline;"></div>
				<h5>Oops! Please Choose Another Email...</h5>
				<div style="clear: both"></div>
			</div>
			<div class="gritter-bottom"></div>
		</div>
	</div>
</div>
<?php
	
	} else {
		
		{
			$encrypt_pass = $password->stringbreak ( $register ['password'] );
			$query = $db->insert ( 'users', array ('name' => $name, 'email' => $email1, 
					'password' => $encrypt_pass, 'contact' => $contact, 'address' => $address, 
					'privilege' => $paymentdetails . ',' . $newpayments . ',' . $mostawarded . ',
					' . $earlierawards . ',' . $giveanawards . ',' . $employeesdetails . ',' . $newemployees . ',
					' . $clientdetails . ',' . $newclient . ',' . $departments . ',
					' . $newdepartments. ',' .$addinventory . ',' . $viewinventory. ',
					' .$addlocation. ',' .$viewlocation,
					'type'=>$type ) );
			
			// $db->debug();
			if ($query) {
				?>
<div id="hide">
	<div id="gritter-notice-wrapper">
		<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
			style="">
			<div class="gritter-top"></div>
			<div class="gritter-item">

				<div class="gritter-without-image">
					<span class="gritter-title">Cheers..
						<div class="gritter-close" id="gritterremove"
							style="display: inline;"></div>
					</span>
					<p><?php echo "Hey!".'&nbsp;'.$name; ?><br>Registered
						Successfully...
					</p>
				</div>
				<div style="clear: both"></div>
			</div>
			<div class="gritter-bottom"></div>
		</div>
	</div>
</div>
<?php
			
			} 

			else {
				?>
<div class="hide1">
	<div id="gritter-notice-wrapper">
		<div id="gritter-item-2" class="gritter-item-wrapper gritter-warning"
			style="">
			<div class="gritter-top"></div>
			<div class="gritter-item">
				<div class="gritter-close" id="gritterremove"
					style="display: inline;"></div>
				<h5>Oops! There Is Some Problem In Inserted..</h5>
				<div style="clear: both"></div>
			</div>
			<div class="gritter-bottom"></div>
		</div>
	</div>
</div>
<?php
			
			}
	}
	}
}
?>