Inventory Search

[insert_php]

$s = trim($_GET[‘partnumlookup’]);

$regex_validate = ‘/^[a-z0-9-\.\s]+$/i’;

if ($s == ‘Inventory Search’) {
$s = ”;
} elseif (empty($s)) {
echo “

Search for a part

“;
echo “

“;
} elseif ( !preg_match($regex_validate, $s) ) {
echo “

Invalid Characters – Please use only alphanumeric characters, \”-\”, and \”.\”

“;
echo “

Search for a part

“;
echo “

“;
} else {
echo “

Search Results for ” . htmlspecialchars($s) . “

“;
$domain = “backoffice.pemnet.com”;
if (gethostbyname($domain) == $domain) $domain = “www.pemnet.com”;
$x = trim(file_get_contents(“http://$domain/inv/api_partslist.php?PartNumLookup=$s”));
if (!empty($x)) {
echo “

“;
foreach (explode(“\n”, $x) as $partnum) {
$link = “Show Inventory“;
echo “

“;
}
echo “

” . htmlspecialchars($partnum) . “ $link

“;
}
else {
echo “

Your search returned no values

“;
}
}

[/insert_php]