$all_vlans = Vlan_database::get_all_vlans(); $exist = false; //check if the distinguisher and vlan id are the same foreach ($all_vlans as $id => $vlan_id) { if ($vlan_id == $_POST['id']) { $t_vlan = new Vlan_database($id); if ($t_vlan->get_vlan_distinguisher() == $_POST['distinguish']) { //if both are same then this vlan exists $exist = true; } } } //if it doesn't exist then start adding if (!$exist) { //set the information $my_vlan->set_vlan_id($_POST['id']); $my_vlan->set_name($_POST["name"]); $my_vlan->set_status($_POST["status"]); $my_vlan->set_location($_POST["location"]); $my_vlan->set_assigned_to($_POST["assign"]); $my_vlan->set_notes($_POST["notes"]); $my_vlan->set_vlan_distinguisher($_POST['distinguish']); //insert a new vlan, if inserted then show the new vlan if ($new_id = $my_vlan->insert()) { echo "<meta http-equiv=\"REFRESH\" content=\"0;url=" . $_SERVER['SCRIPT_NAME'] . "?tab=" . $_GET['tab'] . "&pluginID=" . $_GET['pluginID'] . "&className=" . $_GET['className'] . "&family=vlan&success=add\">"; } else { //if it failed show why Form::warning("INSERT Failed. Reason: " . $my_vlan->get_error()); } } else { //if check failed, show that