ok
Direktori : /home2/selectio/www/lilyexpresslive/software/admin/ |
Current File : /home2/selectio/www/lilyexpresslive/software/admin/pincode-add.php |
<?php require_once('header.php'); ?> <?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['city'])) { $valid = 0; $error_message .= 'City can not be empty<br>'; } if(empty($_POST['state'])) { $valid = 0; $error_message .= 'State can not be empty<br>'; } if(empty($_POST['service'])) { $valid = 0; $error_message .= 'Service can not be empty<br>'; } if(empty($_POST['tat'])) { $valid = 0; $error_message .= 'TAT can not be empty<br>'; } if(empty($_POST['areacode'])) { $valid = 0; $error_message .= 'Area Code can not be empty<br>'; } $code=$_POST['pincode']; $statement = $pdo->prepare("SELECT * FROM pincode where pin_code='$code'"); $statement->execute(); $result = $statement->fetchAll(PDO::FETCH_ASSOC); // $rows = mysqli_num_rows($result); if($result) { $valid=0; $error_message .= 'Pincode Alreay Exist<br>'; } if($valid==1) { $statement = $pdo->prepare("INSERT INTO pincode (pin_code,city,state,service,air,road,tat,area_code) VALUES (?,?,?,?,?,?,?,?)"); $statement->execute(array($_POST['pincode'],$_POST['city'],$_POST['state'],$_POST['service'],$_POST['air'],$_POST['road'],$_POST['tat'],$_POST['areacode'])); $success_message = 'Pincode is added successfully!'; unset($_POST['pincode']); unset($_POST['city']); unset($_POST['state']); unset($_POST['service']); unset($_POST['air']); unset($_POST['road']); unset($_POST['tat']); unset($_POST['area_code']); } } ?> <section class="content-header"> <div class="content-header-left"> <h1>Add Pincode</h1> </div> <div class="content-header-right"> <a href="pincode.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"> <input type="text" autocomplete="off" class="form-control" name="pincode" value="<?php if(isset($_POST['pincode'])){echo $_POST['pincode'];} ?>"> </div> </div> <div class="form-group"> <label for="" class="col-sm-2 control-label">City <span>*</span></label> <div class="col-sm-6"> <input type="text" autocomplete="off" class="form-control" name="city" value="<?php if(isset($_POST['city'])){echo $_POST['city'];} ?>"> </div> </div> <div class="form-group"> <label for="" class="col-sm-2 control-label">State <span>*</span></label> <div class="col-sm-6"> <input type="text" autocomplete="off" class="form-control" name="state" value="<?php if(isset($_POST['state'])){echo $_POST['state'];} ?>"> </div> </div> <div class="form-group"> <label for="" class="col-sm-2 control-label">Service <span>*</span></label> <div class="col-sm-6"> <select class="form-control" name="service"> <?php if(isset($_POST['service'])) { ?> <option value="<?php echo $_POST['service'];?>"><?php echo $_POST['service'];?></option> <?php } ?> <option value="Yes">Yes</option> <option value="No">No</option> </select> </div> </div> <div class="form-group"> <label for="" class="col-sm-2 control-label">Air <span>*</span></label> <div class="col-sm-6"> <select class="form-control" name="air"> <?php if(isset($_POST['air'])) { ?> <option value="<?php echo $_POST['air'];?>"><?php echo $_POST['air'];?></option> <?php } ?> <option value="Yes">Yes</option> <option value="No">No</option> </select> </div> </div> <div class="form-group"> <label for="" class="col-sm-2 control-label">Road <span>*</span></label> <div class="col-sm-6"> <select class="form-control" name="road"> <?php if(isset($_POST['road'])) { ?> <option value="<?php echo $_POST['road'];?>"><?php echo $_POST['road'];?></option> <?php } ?> <option value="Yes">Yes</option> <option value="No">No</option> </select> </div> </div> <div class="form-group"> <label for="" class="col-sm-2 control-label">TAT <span>*</span></label> <div class="col-sm-6"> <input type="text" autocomplete="off" class="form-control" name="tat" value="<?php if(isset($_POST['tat'])){echo $_POST['tat'];} ?>"> </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="areacode" value="<?php if(isset($_POST['areacode'])){echo $_POST['areacode'];} ?>"> </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'); ?>