2603.0 - First effort...
This commit is contained in:
174
add_type_frm.php
Normal file
174
add_type_frm.php
Normal file
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
//SECURE PAGE
|
||||
session_start();
|
||||
if (!isset( $_SESSION['user_id'] ) ) {
|
||||
// Redirect them to the login page
|
||||
header("Location: login.php");
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
include('header.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
//validate form
|
||||
<!--
|
||||
function verificare(form)
|
||||
{
|
||||
if(form.listtype.value == "") {
|
||||
alert ("Please select one of the following actions: Blacklist or Whitelist");
|
||||
form.button2.focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
if(form.bulk.value == "") {
|
||||
alert ("Please write a row for the IP entry");
|
||||
form.bulk.focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
-->
|
||||
</script>
|
||||
|
||||
|
||||
<?php
|
||||
include('topmenu.php');
|
||||
include('conn.php');
|
||||
include('functions.php');
|
||||
|
||||
?>
|
||||
<?php
|
||||
//echo $_POST['edit'];
|
||||
if(isset($_GET['tp']) && ($_GET['tp']<>'-1')){
|
||||
$old_type=$_GET['tp'];
|
||||
$sql_find_type="SELECT * FROM type WHERE type='$old_type'";
|
||||
$rez_find_type=mysqli_query($con,$sql_find_type);
|
||||
|
||||
if(mysqli_num_rows($rez_find_type)==1){
|
||||
//echo "here";
|
||||
$rd_t=mysqli_fetch_array($rez_find_type);
|
||||
$lbl=$rd_t['label'];
|
||||
$stat=$rd_t['status'];
|
||||
|
||||
if($stat==1){
|
||||
$status_sel_a="checked";
|
||||
$status_sel_i="";
|
||||
}
|
||||
else{
|
||||
$status_sel_a="";
|
||||
$status_sel_i="checked";
|
||||
}
|
||||
}
|
||||
else{
|
||||
$type="";
|
||||
$lbl="";
|
||||
$stat="";
|
||||
$status_sel_a="";
|
||||
$status_sel_i="";
|
||||
}
|
||||
$update="yes";
|
||||
}
|
||||
else{
|
||||
//echo "here 2";
|
||||
$old_type="";
|
||||
$lbl="";
|
||||
$stat="";
|
||||
$status_sel_a="";
|
||||
$status_sel_i="";
|
||||
$update="no";
|
||||
}
|
||||
|
||||
?>
|
||||
<div style="padding-left:20px">
|
||||
<h2>Add /Edit Type of entry</h2>
|
||||
<br>
|
||||
<form name="ip" action="add_type_save.php" method="POST" class="form-horizontal" onSubmit="return verificare(this);">
|
||||
<div class="form-group">
|
||||
<div class="row line10">
|
||||
<div class="col-sm-2">
|
||||
<input type="hidden" name="action" value="<?php echo $update;?>">
|
||||
<input type="hidden" name="old_type" value="<?php echo $old_type;?>">
|
||||
</div>
|
||||
<div class="form-check form-check-inline col-sm-8">
|
||||
<label class="form-check-label" for="button2" style="margin-right:20px">
|
||||
<input class="form-check-input" type="radio" name="status" id="button2" value="a" <?php echo "$status_sel_a";?> >
|
||||
Active
|
||||
</label>
|
||||
<label class="form-check-label" for="button3">
|
||||
<input class="form-check-input" type="radio" name="status" id="button3" value="i" <?php echo "$status_sel_i";?>>
|
||||
Inactive
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row line10">
|
||||
<label class="col-sm-2 control-label">Type
|
||||
</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="type" type="text" placeholder="Enter numeric value for Type" class="form-control" value="<?php echo $old_type;?>"><br>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row line10">
|
||||
<label class="col-sm-2 control-label">Label </label>
|
||||
|
||||
<div class="col-sm-8"><input name="label" type="text" placeholder="Enter label for Type - e.g. Manual entry" class="form-control" value="<?php echo $lbl;?>"><br>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row line10">
|
||||
<div class="col-sm-2"></div>
|
||||
<div class="col-sm-8">
|
||||
<input type="submit" value="Save" class="btn btn-primary" name='save'>
|
||||
<input type="button" value="Cancel" class="btn btn-warning" onclick='window.location.href="<?php echo"add_type_frm.php?"; ?>"'>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
//display existing values in type table
|
||||
$sql_type="SELECT * FROM type ORDER BY type ASC";
|
||||
$rez_type=mysqli_query($con,$sql_type);
|
||||
|
||||
if(mysqli_num_rows($rez_type)>0){
|
||||
echo "<div class='row line10'>
|
||||
<div class='col-sm-2'>
|
||||
</div>
|
||||
<div class='col-sm-8'>
|
||||
<div style='text-align:center'>";
|
||||
echo "<div style='display:inline-block; width:100%'>";
|
||||
echo "<form method='post'><table class='table table-condensed table-striped table-hover' style='text-align:left'>";
|
||||
echo "<tr>
|
||||
<th>Type</th>
|
||||
<th>Label</th>
|
||||
<th>Status</th>
|
||||
<th>Edit</th>
|
||||
</tr>";
|
||||
while($rd_tp=mysqli_fetch_array($rez_type)){
|
||||
|
||||
echo "<tr>";
|
||||
$tp=$rd_tp['type'];
|
||||
echo "<td>".$rd_tp['type']."</td>";
|
||||
echo "<td>".$rd_tp['label']."</td>";
|
||||
|
||||
if($rd_tp['status']==1){
|
||||
echo "<td>Active</td>";
|
||||
}
|
||||
else{
|
||||
echo "<td>Inactive</td>";
|
||||
}
|
||||
|
||||
echo "<td><form><button type='button' class='btn btn-secondary btn-sm' onclick='window.location.href=\"add_type_frm.php?tp=$tp\";'><i class='fa fa-edit'></i></button></td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
|
||||
echo "</form></table>";
|
||||
echo "</div>
|
||||
</div>";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
include('footer.php');
|
||||
?>
|
||||
Reference in New Issue
Block a user