ok

Mini Shell

Direktori : /home2/selectio/www/lilyexpresslive/software/admin/
Upload File :
Current File : /home2/selectio/www/lilyexpresslive/software/admin/dp-code-add.php

<?php require_once('header.php'); ?>
<script type="text/javascript">
$(document).ready(function(){
    $("#pincode").select2();
});
</script>
<?php
if(isset($_POST['form1'])) {
   // var_dump($_POST);
	$valid = 1;

	if(empty($_POST['pincode'])) {
		$valid = 0;
		$error_message .= 'Pincode can not be empty<br>';
	}

	if(empty($_POST['dp_code'])) {
		$valid = 0;
		$error_message .= 'Dp Code can not be empty<br>';
	}
		if(empty($_POST['area_code'])) {
		$valid = 0;
		$error_message .= 'Area code can not be empty<br>';
	}
		if(empty($_POST['distict'])) {
		$valid = 0;
		$error_message .= 'distict can not be empty<br>';
	}
		

    $code=$_POST['dp_code'];
	$statement = $pdo->prepare("SELECT * FROM dp_code where dp_code='$code'");
	$statement->execute();
	$result = $statement->fetchAll(PDO::FETCH_ASSOC);
	$rows = mysqli_num_rows($result);
    if($result)
    {
        $valid=0;
        $error_message .= 'Dp Code Alreay Exist<br>';
    }
							

    if($valid==1)
    {
    
		$statement = $pdo->prepare("INSERT INTO dp_code (pincode,dp_code,area_code,distict) VALUES (?,?,?,?)");
		$statement->execute(array($_POST['pincode'],$_POST['dp_code'],$_POST['area_code'],$_POST['distict']));
			
		$success_message = 'Dp Code is added successfully!';

		unset($_POST);
    }
	
}
?>

<section class="content-header">
	<div class="content-header-left">
		<h1>Add Dp-code</h1>
	</div>
	<div class="content-header-right">
		<a href="dp-code.php" class="btn btn-primary btn-sm">View All</a>
	</div>
</section>


<section class="content">

	<div class="row">
		<div class="col-md-12">

			<?php if($error_message): ?>
			<div class="callout callout-danger">
				<p>
					<?php echo $error_message; ?>
				</p>
			</div>
			<?php endif; ?>

			<?php if($success_message): ?>
			<div class="callout callout-success">
				<p><?php echo $success_message; ?></p>
			</div>
			<?php endif; ?>
			
			<form class="form-horizontal" action="" method="post" enctype="multipart/form-data">
				<div class="box box-info">
					<div class="box-body">
						
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Pincode <span>*</span></label>
							<div class="col-sm-6">
				<select class="form-control" name="pincode" id="pincode">
							<?php	$statement = $pdo->prepare("SELECT * FROM pincode ORDER BY id ASC");
			$statement->execute();
			$result = $statement->fetchAll(PDO::FETCH_ASSOC);	
			foreach ($result as $row) {
				?>
				<option value="<?php echo $row['pin_code']; ?>"><?php echo $row['pin_code']; ?>-<?php echo $row['area_code']; ?>-<?php echo $row['city']; ?></option>
				<?php
			} ?>
			</select>
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Dp Code <span>*</span></label>
							<div class="col-sm-6">
								<input type="text" autocomplete="off" class="form-control" name="dp_code" value="<?php if(isset($_POST['dp_code'])){echo $_POST['dp_code'];} ?>">
							</div>
						</div>

						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Area Code <span>*</span></label>
							<div class="col-sm-6">
								<input type="text" autocomplete="off" class="form-control" name="area_code" value="<?php if(isset($_POST['area_code'])){echo $_POST['area_code'];} ?>">
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">District <span>*</span></label>
							<div class="col-sm-6">
								<input type="text" autocomplete="off" class="form-control" name="distict" value="<?php if(isset($_POST['distict'])){echo $_POST['distict'];} ?>">
							</div>
						</div>
					
						<div class="form-group">
							<label for="" class="col-sm-2 control-label"></label>
							<div class="col-sm-6">
								<button type="submit" class="btn btn-success pull-left" name="form1">Submit</button>
							</div>
						</div>
					</div>
				</div>
			</form>
		</div>
	</div>

</section>

<?php require_once('footer.php'); ?>

Zerion Mini Shell 1.0