ok

Mini Shell

Direktori : /proc/thread-self/root/home2/selectio/public_html/lilyexpresslive/software/admin/
Upload File :
Current File : //proc/thread-self/root/home2/selectio/public_html/lilyexpresslive/software/admin/user-add.php

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

<?php
if(isset($_POST['form1'])) {
   // var_dump($_POST);
	$valid = 1;

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

	if(empty($_POST['email'])) {
		$valid = 0;
		$error_message .= 'email can not be empty<br>';
	}
	if(empty($_POST['gst_no'])) {
		$valid = 0;
		$error_message .= 'GST Number can not be empty<br>';
	}
		if(empty($_POST['phone'])) {
		$valid = 0;
		$error_message .= 'Phone No can not be empty<br>';
	}

	if(empty($_POST['address'])) {
		$valid = 0;
		$error_message .= 'Address can not be empty<br>';
	}
		if(empty($_POST['location'])) {
		$valid = 0;
		$error_message .= 'Location can not be empty<br>';
	}
		if(empty($_POST['status'])) {
		$valid = 0;
		$error_message .= 'Status Code can not be empty<br>';
	}
		if(empty($_POST['password'])) {
		$valid = 0;
		$error_message .= 'Password can not be empty<br>';
	}

$code=$_POST['phone'];

$statement = $pdo->prepare("SELECT * FROM tbl_user WHERE full_name=?");
	$statement->execute(array(str_replace(' ', '', strtoupper($_POST['full_name']))));
	$total = $statement->rowCount();

if($total>0){
    $error_message="Client Name Already Existing...";
    $valid = 0;
}


// 	$statement = $pdo->prepare("SELECT * FROM tbl_user where phone='$code'");
// 							$statement->execute();
// 							$result = $statement->fetchAll(PDO::FETCH_ASSOC);
//                             if($result)
//                             {
//                                 $valid=0;
//                                 $error_message .= 'Phone No Alreay Exist<br>';
//                             }


    if($valid==1)
    {
    
		$statement = $pdo->prepare("INSERT INTO tbl_user (full_name,email,gst_no,phone,address,location,status,password,role,short_location,branch_id) VALUES (?,?,?,?,?,?,?,?,?,?,?)");
		$statement->execute(array($_POST['full_name'],$_POST['email'],$_POST['gst_no'],$_POST['phone'],$_POST['address'],$_POST['location'],$_POST['status'],$_POST['password'],$_POST['role'],$_POST['short_location'],$_POST['branch_id']));
			
		$success_message = 'Client is added successfully!';

		unset($_POST['full_name']);
		unset($_POST['email']);
		unset($_POST['gst_no']);
		unset($_POST['phone']);
		unset($_POST['address']);
		unset($_POST['status']);
		unset($_POST['location']);
		unset($_POST['password']);
		unset($_POST['short_location']);
	
    }
	
}
?>

<section class="content-header" style="background-color: white;">
	
	<div class="row">
		<div class="col-md-8" style="text-align: center;">
			<h4><i class="fa fa-user-plus"></i> Add Client</h4>
		</div>
		<div class="col-md-4">
			<a href="user.php" class="btn btn-danger btn-sm"><i class="fa fa-user-plus"></i> Back to Client List</a>
		</div>
	</div>
</section>


<section class="content" style="background-color: white;">

	<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 >
					<div class="box-body">




									<div class="form-group">	
			<label for="" class="col-sm-2 control-label">Branch Name <span>*</span></label>
										<div class="col-sm-6">  
										<select class="form-control select2" name="branch_id" id="branch_id">    
				        <?php
						$statement = $pdo->prepare("SELECT * FROM tbl_branch WHERE status='Active'  ORDER BY id ASC");
						$statement->execute();
						$result = $statement->fetchAll(PDO::FETCH_ASSOC);	
						foreach ($result as $row) {
							?>
							<option value="<?php echo $row['id']; ?>" ><?php echo $row['branch_name']; ?></option>
							<?php
						}
						?>
				    </select>
				</div>
			</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Client Name <span>*</span></label>
							<div class="col-sm-6">
								<input type="text" autocomplete="off" class="form-control" name="full_name" value="<?php if(isset($_POST['full_name'])){echo $_POST['full_name'];} ?>" style="text-transform:uppercase">
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Email <span>*</span></label>
							<div class="col-sm-6">
								<input type="text" autocomplete="off" class="form-control" name="email" value="<?php if(isset($_POST['email'])){echo $_POST['email'];} ?>">
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Phone Number <span>*</span></label>
							<div class="col-sm-6">
								<input type="text" autocomplete="off" class="form-control" name="phone" value="<?php if(isset($_POST['phone'])){echo $_POST['phone'];} ?>">
							</div>
						</div>
							<div class="form-group">
							<label for="" class="col-sm-2 control-label">GST Number <span>*</span></label>
							<div class="col-sm-6">
								<input type="text" autocomplete="off" class="form-control" name="gst_no" value="<?php if(isset($_POST['gst_no'])){echo $_POST['gst_no'];} ?>" style="text-transform:uppercase">
							</div>
						</div>
							<div class="form-group">
							<label for="" class="col-sm-2 control-label">Address <span>*</span></label>
							<div class="col-sm-6">
								<input type="text" autocomplete="off" class="form-control" name="address" value="<?php if(isset($_POST['address'])){echo $_POST['address'];} ?>">
							</div>
						</div>
							<div class="form-group">
							<label for="" class="col-sm-2 control-label">Location <span>*</span></label>
							<div class="col-sm-6">
								<input type="text" autocomplete="off" class="form-control" name="location" value="<?php if(isset($_POST['location'])){echo $_POST['location'];} ?>" style="text-transform:uppercase">
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Location Shortcode<span>*</span></label>
							<div class="col-sm-6">
								<input type="text" autocomplete="off" class="form-control" name="short_location" value="<?php if(isset($_POST['short_location'])){echo $_POST['short_location'];} ?>" style="text-transform:uppercase">
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Password <span>*</span></label>
							<div class="col-sm-6">
								<input type="text" autocomplete="off" class="form-control" name="password" value="<?php if(isset($_POST['password'])){echo $_POST['password'];} ?>">
							</div>
						</div>
						<div class="form-group" >
							<label for="" class="col-sm-2 control-label">Client Type <span>*</span></label>
							<div class="col-sm-6">
							    <select class="form-control select2" name="role" id="role">
							        <option value="Modicare"  <?php if(isset($_POST['role'])) {if($_POST['role']=='Modicare'){echo "selected";}} ?>>Modicare</option>
							        <option value="Cargo" <?php if(isset($_POST['role'])) {if($_POST['role']=='Cargo'){echo "selected";}} ?>>Cargo</option>
							    </select>
							</div>
						</div>
						
							<div class="form-group">
							<label for="" class="col-sm-2 control-label">Status <span>*</span></label>
							<div class="col-sm-6">
							    <select class="form-control select2" name="status" id="status">
							        <!--<option >Select Client Status</option>-->
							        <option value="Active"  <?php if(isset($_POST['status'])) {if($_POST['status']=='Active'){echo "selected";}} ?>>Active</option>
							        <option value="Inactive" <?php if(isset($_POST['status'])) {if($_POST['status']=='Inactive'){echo "selected";}} ?>>Inactive</option>
							    </select>
							</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