Location: PHPKode > projects > OpenCabling > opencabling/edit_vlan.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></meta>
<link rel="stylesheet" href="css/opencabling.css" type="text/css"></link>
<?php
require_once 'js/functions.js';

?>

</head>
<body>
<?php

include "opendb.php";

$action=$_REQUEST['action'];
$vlanname_id=$_REQUEST['vlanname_id'];
$object=$_REQUEST['object'];
$name=$_REQUEST['name'];
$vlanid=$_REQUEST['vlanid'];
$localid=$_REQUEST['localid'];

if ($action=="add") {
  $sql="insert into vlannames(name,obj_id,vlanid,localid) values('$name',$object,$vlanid,$localid)";
  $query=mysql_query($sql,$mysql_conn);
} else if ($action=="edit") {
  $sql="update vlannames set name='".$name."', vlanid=".$vlanid.", localid=".$localid." where vlanname_id=".$vlanname_id;
  $query=mysql_query($sql,$mysql_conn);
}

if ($action<>"") {
  echo "<script lang=javascript>opener.location.href = 'show_detail.php?object=".$object."'; window.close();</script>";
} else {
  
  if ($vlanname_id=="") {
    $action="add";
  } else {
    $action="edit";
  }
    
  if ($action=="edit") {
    $sql="select * from vlannames where vlanname_id=$vlanname_id";
    $query=mysql_query($sql,$mysql_conn);
    $result=mysql_fetch_assoc($query);
    $name=$result['name'];
    $vlanid=$result['vlanid'];
    $localid=$result['localid'];
    print "Edit vlan definition:";
  } else {
    print "Adding the following vlan definition:";
  }
  print "<form method=post action='edit_vlan.php'>";
  print "<table>";
  print "<tr><td align=right><b>VLAN Name:</b></td><td><input type=text name=name value='$name'></input></td></tr>";
  print "<tr><td align=right><b>VLAN ID:</b></td><td><input type=text name=vlanid value='$vlanid'></input></td></tr>";
  print "<tr><td align=right><b>Local ID:</b></td><td><input type=text name=localid value='$localid'></input></td></tr>";
  print "<tr><td></td><td align=right>";
  print "<input type=hidden name=action value='$action'></input>";
  print "<input type=hidden name=vlanname_id value='$vlanname_id'></input>";
  print "<input type=hidden name=object value='$object'></input>";
  print "<input type=submit value='Submit'></input>";
  print "</td></tr></table>";
}

?>
</body>
</html>
Return current item: OpenCabling