<?PHP include("config.php");

?>

<form method=get>
eml_code: <input type=text name=eml_code><input type=submit>
</form>

<?
if ($_REQUEST['eml_code']) {
        $code = mysql_escape_string($_REQUEST['eml_code']);

        $q = "Select * from glist_EmailMailings where eml_code like '%${code}%'";
        $query = mysql_query($q) or die(mysql_error());

        $r = mysql_num_rows($query);
        if ($r == 0) {
                echo "No email found with that code";
        } elseif ($r > 50) {
                echo "More than 50 results found";
        } else { 
                echo "<table width=500>";
                echo "<tr><th>Email Address</th><th>Code</th></tr>";
                while ($row = mysql_fetch_array($query)) {
                        echo "<tr><td nowrap>" . $row[eml_email] . "</td><td nowrap>" . $row[eml_code] . "</td></tr>";
                }
                echo "</table>";
        }

}
?>