File: /var/www/html/company_app/company/edit.php
<?php
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
require '../include/functions.php';
if(!isset($_SESSION["email"]))
{
header('Location: '.getParentDir().'/index.html');
}
$company_id = isset($_GET['company_id']) ? $_GET['company_id'] : '';
global $conn;
$sql = "SELECT * FROM companies where company_id = '$company_id' order by id desc limit 0,1";
$result = $conn->query($sql);
$company_id = '';
$company_name = '';
$scheduler_time='';
$end_url = '';
$status = '';
if ($result->num_rows > 0) {
// output data of each row
$k=1;
while($row = $result->fetch_assoc())
{
$company_id = $row['company_id'];
$company_name = $row['company_name'];
$scheduler_time = $row['scheduler_time'];
$end_url = $row['end_url'];
$status = $row['status'];
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Add company | API</title>
<?php include '../include/head.php'; ?>
</head>
<body>
<div id="wrapper">
<!-- Navigation -->
<?php include '../include/sidenav.php'; ?>
<div id="page-wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Campany Add</h1>
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
<div class="row">
<div class="col-lg-6">
<form role="form" method="post" action="<?php echo getParentDir();?>/include/functions.php?option=edit_company">
<input type="hidden" name="company_id" value="<?php echo $company_id; ?>">
<div class="form-group">
<label>Company ID</label>
<input class="form-control" placeholder="Enter Company ID" name="company_id" value="<?php echo $company_id; ?>" onkeypress='return formats(this,event)' onkeyup="return numberValidation(event)" required>
<p class="help-block">Ex: 0000-0000-0000-0000</p>
</div>
<div class="form-group">
<label>Company Name</label>
<input class="form-control" placeholder="Enter Company Name" name="company_name" value="<?php echo $company_name; ?>" required>
<p class="help-block">Ex: xyz</p>
</div>
<div class="form-group">
<label>Salesforce API End URL</label>
<input class="form-control" placeholder="Enter API End URL" name="end_url" value="<?php echo $end_url; ?>" required>
<p class="help-block">Ex: https://login.salesforce.com</p>
</div>
<div class="form-group">
<label>Scheduler Time (In Sec)</label>
<select class="form-control" name="scheduler_time" required>
<option value="">Select scheduler time</option>
<?php
for($h=1; $h <= 3600; $h++)
{
?>
<option <?php if($h == $scheduler_time) { ?>selected<?php } ?> value="<?php echo $h; ?>"><?php echo $h." (Sec)"; ?></option>
<?php
}
?>
</select>
</div>
<div class="form-group">
<label>status</label>
<select class="form-control" name="status" required>
<option value="">Select Status</option>
<option <?php if($status == '1') { ?>selected<?php } ?> value="1">Activated</option>
<option <?php if($status == '0') { ?>selected<?php } ?> value="0">Deactivated</option>
</select>
</div>
<br/>
<button type="submit" class="btn btn-primary">Update</button>
</form>
<?php
?>
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
</div>
<!-- /.container-fluid -->
</div>
<!-- /#page-wrapper -->
</div>
<!-- /#wrapper -->
<?php include '../include/footer.php'; ?>
<script>
function formats(ele,e){
if(ele.value.length<19){
ele.value= ele.value.replace(/\W/gi, '').replace(/(.{4})/g, '$1 ');
return true;
}else{
return false;
}
}
function numberValidation(e){
e.target.value = e.target.value.replace(/[^\d ]/g,'');
return false;
}
</script>
</body>
</html>