Examples: PHP/MySQL
Example #1
<?php
include("mysql/cwhois.php");
$cwObj = new CMyCWhois();
if (!$cwObj->connect($host, $login, $passwd, $base, $table)) {
die($cwObj->getLastError());
}
echo "Hello, you are visiting us from <B>".$cwObj->getNameByAddr($_SERVER["REMOTE_ADDR"])."</B>";
?>
view
Example #2
<form action="" method="POST">
<textarea name="address"></textarea><input type="submit" value="Request">
</form>
<table>
<tr>
<th>Address</th>
<th>Code</th>
<th>Country</th>
</tr>
<?php
if ("POST" == $_SERVER["REQUEST_METHOD"]) {
$addr = preg_split("/\s+/s", trim($_POST["address"]));
if (count($addr) > 0) {
include("mysql/cwhois.php");
$cwObj = new CMyCWhois();
if (!$cwObj->connect($host, $login, $passwd, $base, $table)) {
die($cwObj->getLastError());
}
foreach ($addr as $key=>$val) {
$country = $cwObj->getCountryByAddr($val);
?>
<tr>
<td><?php echo $val?></td>
<td><?php echo $country[0]?></td>
<td><?php echo $country[1]?></td>
</tr>
<?php
}
}
}
?>
</table>
view