<body>
<?php
if ($Submit)
{
mysql_connect("localhost","xxxx","xxxx");
mysql_select_db("xxxx");if ($textfield1 == ""){
$data = array();
$result = mysql_query("SELECT col_IP,col_PORT From scanip;");
while ($row = mysql_fetch_assoc($result)) {
    $data[] = $row["col_IP"] . ':' . $row["col_PORT"];
}
mysql_free_result($result);
file_put_contents('ip.txt', implode("\r\n",$data));
}else{
$sql="insert into scanip(col_IP,col_PORT) values ('$textfield1','$textfield2')";
mysql_query($sql);
}}else{
?>
<form method="post" action="<?php echo $PATH_INFO ?>">
             IP:<input type="text" name="textfield1"> 
             Port:<input type="text" name="textfield2">
             <input type="Submit" name="Submit" value="提交/查询">
</form>
<?php
}
?>
</body>