ok

Mini Shell

Direktori : /home2/selectio/public_html/lilyexpresslive/software/admin/
Upload File :
Current File : /home2/selectio/public_html/lilyexpresslive/software/admin/user-edit.php

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

<?php
if(isset($_POST['form1'])) {
	$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['phone'])) {
		$valid = 0;
		$error_message .= 'Phone can not be empty<br>';
	}
		if(empty($_POST['gst_no'])) {
		$valid = 0;
		$error_message .= 'GST Number can not be empty<br>';
	}

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

	if($valid == 1) {

        	$statement = $pdo->prepare("UPDATE tbl_user SET full_name=?, email=?, phone=?,address=?, gst_no=?,location=?, status=?,password=?,short_location=?,branch_id=? WHERE id=?");
    		$statement->execute(array($_POST['full_name'],$_POST['email'],$_POST['phone'],$_POST['address'],$_POST['gst_no'],$_POST['location'],$_POST['status'],$_POST['password'],$_POST['short_location'],$_POST['branch_id'],$_REQUEST['id']));

	    $success_message = 'Users is updated successfully!';
	}
}
?>

<?php
if(!isset($_REQUEST['id'])) {
	header('location: logout.php');
	exit;
} else {
	// Check the id is valid or not
	$statement = $pdo->prepare("SELECT * FROM tbl_user WHERE id=?");
	$statement->execute(array($_REQUEST['id']));
	$total = $statement->rowCount();
	$result = $statement->fetchAll(PDO::FETCH_ASSOC);
	if( $total == 0 ) {
		header('location: logout.php');
		exit;
	}
}
?>
<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> Edit Clients</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>

<?php
$statement = $pdo->prepare("SELECT * FROM tbl_user WHERE id=?");
$statement->execute(array($_REQUEST['id']));
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
	$full_name = $row['full_name'];
	$email = $row['email'];
	$phone = $row['phone'];
	$address = $row['address'];
	$status = $row['status'];
	$password = $row['password'];
	$gst_no = $row['gst_no'];
	$short_location = $row['short_location'];
	$location = $row['location'];
	$branch_id = $row['branch_id'];

}
?>

<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 role_type=2  ORDER BY id ASC");
			$statement->execute();
			$result = $statement->fetchAll(PDO::FETCH_ASSOC);	
			foreach ($result as $row) {
				?>
				<option value="<?php echo $row['id']; ?>" <?php if($branch_id==$row['id']){echo "selected";}?> ><?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 echo $full_name; ?>" required>
							</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" class="form-control" name="email" value="<?php echo $email; ?>" required>
							</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" class="form-control" name="phone" value="<?php echo $phone; ?>" required>
							</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" class="form-control" name="gst_no" value="<?php echo $gst_no; ?>" required>
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Address <span>*</span></label>
							<div class="col-sm-6">
							    <textarea class="form-control" name="address" required><?php echo $address; ?></textarea>
							
							</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" class="form-control" name="location" value="<?php echo $location; ?>" required>
							</div>
						</div>
							<div class="form-group">
							<label for="" class="col-sm-2 control-label">Short Location <span>*</span></label>
							<div class="col-sm-6">
								<input type="text" class="form-control" name="short_location" value="<?php echo $short_location; ?>" required>
							</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" class="form-control" name="password" value="<?php echo $password; ?>" required>
							</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" name="status" id="status">
							        <option value="Active"  <?php if(isset($status)) {if($status=='Active'){echo "selected";}} ?>>Active</option>
							        <option value="Inactive" <?php if(isset($status)) {if($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"><i class="fa fa-user-plus"></i> Submit</button>
							</div>
						</div>
					</div>
				</div>
			</form>
		</div>
	</div>

</section>

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

Zerion Mini Shell 1.0