Not sure why the last section won't work...

/* Function to search for hosts */
function search_dhcp() {
if ((empty($_POST['search'])) && (empty($_POST['hosts01'])) && (empty($_POST['hn'])) && (empty($_POST['ma'])) && (empty($_POST['i'])) && (empty($_POST['v']))) {
unset($_SESSION['search']);
$_SESSION['search'] = "<b>Search for individual computers to edit</b><br><br><span class=\"copyright\">**This feature will search all VLAN's for individual machines to make host configuration changes to.<br>ex. 10.10.0.255 or dhcp-client<br> Wildcards are marked as a '%'.</span><br><br><form action=\"$_SERVER[PHP_SELF]\" method=\"post\" name=\"search\"><input name=\"search_name\" type=\"text\" size=\"30\" maxlength=\"45\"><br><br><input name=\"search\" type=\"submit\" value=\"search\"></form>";
} elseif ((!empty($_POST['search_name'])) && (empty($_POST['hosts01'])) && (empty($_POST['hn'])) && (empty($_POST['ma'])) && (empty($_POST['i'])) && (empty($_POST['v']))) {
unset($_SESSION['search']);
require 'dbase.inc.php';
$table = "hosts";
$x = @mysql_query("SELECT * FROM $table WHERE hostname LIKE '$_POST[search_name]'")or die(mysql_error());
$num = mysql_num_rows($x);
if($num == "0") {
$_SESSION['search'] = "<b>Search for individual computers to edit by hostname</b><br><br><span class=\"copyright\">**This feature will search all VLAN's for individual machines to make host configuration changes to.<br>(ex. dhcp_client_003) Wildcards are marked as a '%'.</span><br><br><b><img src=\"images/error.jpg\">&nbsp;&nbsp;No hosts matched your search for $_POST[search_name].</b><br><br><form action=\"$_SERVER[PHP_SELF]\" method=\"post\" name=\"search\"><input name=\"search_name\" type=\"text\" size=\"30\" maxlength=\"45\"><br><br><input name=\"search\" type=\"submit\" value=\"search\"></form>";
} elseif ($num != 0) {
$_SESSION['search'] .= "<b>Here are your search results.</span><br><br><br><span class=\"copyright\">**Please select the machine you wish to make changes to.</span><br><br><form name=\"hosts\" action=\"$_SERVER[PHP_SELF]\" method=\"post\"><select name=\"hosts01\" size=\"5\" multiple>";
while($v = mysql_fetch_array($x)) {
list($_SESSION['id'],$_SESSION['hn'],$_SESSION['ma'],$_SESSION['i'],$_SESSION['v']) = $v;
$_SESSION['search'] .= "<option name=\"$_SESSION[hn]\" value=\"$_SESSION[hn]\">$_SESSION[hn]&nbsp;|&nbsp;$_SESSION[i]&nbsp;|&nbsp;$_SESSION[v]</option>"; }
$_SESSION['search'] .= "</select><br><br><INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"select\"></form>";
} else {
$_SESSION['search'] = "<b>Search for individual computers to edit by hostname<br>(ex. dhcp_client_003)</b><br><br><span class=\"copyright\">**This feature will search all VLAN's for individual machines to make host configuration changes to.</span><br><br><b><img src=\"images/error.jpg\">&nbsp;&nbsp;No hosts matched your search for $_POST[search_name].</b><br><br><form action=\"$_SERVER[PHP_SELF]\" method=\"post\" name=\"search\"><input name=\"search_name\" type=\"text\" size=\"30\" maxlength=\"45\"><br><br><input name=\"search\" type=\"submit\" value=\"search\"></form>"; }
unset($_SESSION['id'],$_SESSION['hn'],$_SESSION['ma'],$_SESSION['i'],$_SESSION['v']);
} elseif ((!empty($_POST['hosts01'])) && (empty($_POST['search'])) && (empty($_POST['hn'])) && (empty($_POST['ma'])) && (empty($_POST['i'])) && (empty($_POST['v']))) {
unset($_SESSION['search']);
require 'dbase.inc.php';
$table = "hosts";
$x = mysql_query("SELECT * FROM $table WHERE hostname = '$_POST[hosts01]' OR ip = '$_POST[hosts01]' OR mac = '$_POST[hosts01]'")or die(mysql_error());
$num = mysql_num_rows($x);
if($num == "0") {
unset($_SESSION['search']);
$_SESSION['search'] = "<b>Search for individual computers to edit by hostname<br>(ex. dhcp_client_003)</b><br><br><span class=\"copyright\">**This feature will search all VLAN's for individual machines to make host configuration changes to.</span><br><br><img src=\"images/error.jpg\">&nbsp;&nbsp;<b>You did not select a host to edit.</b><br><br><form action=\"$_SERVER[PHP_SELF]\" method=\"post\" name=\"search\"><input name=\"search_name\" type=\"text\" size=\"30\" maxlength=\"45\"><br><br><input name=\"search\" type=\"submit\" value=\"search\"></form>";
} elseif ($num != 0) {
while($a = mysql_fetch_array($x)) {
list($_SESSION['id01'],$hn,$ma,$i,$v) = $a; }
$_SESSION['search'] = "<table width=\"100%\" border=\"0\" cellspacing=\"2\">
<form name=\"hosts_done\" method=\"post\" action=\"$_SERVER[PHP_SELF]\">
<tr>
<td width=\"40%\" colspan=\"2\"><b>You are about to make changes to $hn | $i</b><br><br><span class=\"copyright\">** Please fill out all fields and be carefull when entering the MAC address. The proper format is as such XX:XX:XX:XX:XX</span></td>
</tr>
<tr>
<td width=\"40%\">Hostname</td>
<td><input name=\"hn\" value=\"$hn\" size=\"20\" maxlength=\"45\"></td>
</tr>
<tr>
<td>MAC-Address</td>
<td><input name=\"ma\" value=\"$ma\" size=\"20\" maxlength=\"45\"></td>
</tr>
<tr>
<td>IP-Address</td>
<td><input name=\"i\" value=\"$i\" size=\"20\" maxlength=\"45\"></td>
</tr>
<tr>
<td>VLAN / Subnet:</td>
<td><input name=\"v\" value=\"$v\" size=\"20\" maxlength=\"45\"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td ><input name=\"Save\" type=\"submit\" value=\"Save\">&nbsp;&nbsp;<input name=\"reset\" type=\"reset\" value=\"Reset\"></td>
</tr></form></table>";
} elseif ((empty($_POST['hosts01'])) && (empty($_POST['search'])) && (!empty($_POST['hn'])) && (!empty($_POST['ma'])) && (!empty($_POST['i'])) && (!empty($_POST['v']))) {
unset($_SESSION['search']);
// Will not get to this point!!!!!
$_SESSION['search'] = "<table width=\"100%\" border=\"0\" cellspacing=\"2\">
<tr>
<td width=\"40%\" colspan=\"2\"><b>Your changes to $_POST[hosts01] were successfull</b><br><br><span class=\"copyright\">** To make your changes active you must use the \"UPDATE DHCP\" link on the left</span></td>
</tr>
<tr>
<td width=\"40%\">Hostname</td>
<td>$_POST[hn]</td>
</tr>
<tr>
<td>MAC-Address</td>
<td>$_POST[ma]</td>
</tr>
<tr>
<td>IP-Address</td>
<td>$_POST[i]</td>
</tr>
<tr>
<td>VLAN / Subnet:</td>
<td>$_POST[v]</td>
</tr></table>";
} else {
unset($_SESSION['search']);
$_SESSION['search'] = "<img src=\"images/error.jpg\">&nbsp;&nbsp;Something broke, please try again."; }
} else {
unset($_SESSION['search']);
header("Location: login.hosts.php"); }
}


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to