ok

Mini Shell

Direktori : /home2/selectio/www/lilyexpresslive/software/admin/
Upload File :
Current File : /home2/selectio/www/lilyexpresslive/software/admin/system-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['phone'])) {
		$valid = 0;
		$error_message .= 'Phone can not be empty<br>';
	}
		if(empty($_POST['email'])) {
		$valid = 0;
		$error_message .= 'email 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_system_user SET full_name=?, phone=?,address=?, status=?,password=?,email=?,role_ids=? WHERE id=?");
    		$statement->execute(array($_POST['full_name'],$_POST['phone'],$_POST['address'],$_POST['status'],$_POST['password'],$_POST['email'],$_POST['role_name'],$_REQUEST['id']));

	    $success_message = 'System 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_system_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-6" style="text-align: left;"> <a href="system-users.php" class="btn btn-primary btn-sm">View All</a>
			<h4><i class="fa fa-user-plus"></i>Update System Users</h4>
		</div>
		
	</div>
</section>



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

}
?>

<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>
					<div class="box-body">
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">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; ?>" >
							</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; ?>">
							</div>
						</div>
						
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">Email Address <span>*</span></label>
							<div class="col-sm-6">
								<input type="email" class="form-control" name="email" value="<?php echo $email; ?>">
							</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"><?php echo $address; ?></textarea>
							
							</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 >Select Client Status</option>
							        <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">Role Name<span>*</span></label>
							<div class="col-sm-6">
							<select class="form-control select2" name="role_name" id="role_name">
                        	        <?php
                        			$statement = $pdo->prepare("SELECT * FROM tbl_role WHERE status='1' ORDER BY id ASC");
                        			$statement->execute();
                        			$result = $statement->fetchAll(PDO::FETCH_ASSOC);	
                        			foreach ($result as $row) {
                        				?>
                        				<option value="<?php echo $row['id']; ?>" <?php if($row['id']==$role_id){ echo 'selected';} ?>><?php echo $row['role_name']; ?></option>
                        				<?php
                        			}
                        			?>
                    	    </select>
			</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; ?>">
							</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