<?PHP
// --------------------------------------------------------
// ID | userName | password | name | address
// --------------------------------------------------------
// 1 | Tina | ASDF | Lady mae | anston road
// 2 | Lina | FDAS | Lina Abraska | neilton road
// 2 | Susi | AASD | Susianti | kamasa road
//
// And I hope that ID column is primary 🙂
// I made some corrections in your source so
// do not simply copy-paste all
if ( $REQUEST_METHOD!="POST")
{?>
<head><title>Login form</title></head>
<body bgcolor="#ffffff">
<form action="login.php" method="post">
<table border="0">
<tr>
<td><strong>Username</strong></td>
<td><input type="text" name="username" size="10" maxsize="50"></td>
</tr>
<tr>
<td><strong>Password</strong></td>
<td><input type="password" name="password" size="10" maxsize="50"</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="Auth me">
</td>
</tr>
</table>
</form>
</body>
<?}else{
mysql_connect("localhost", "root", "F0AA2pa8") or die ("Unable to connect to server.");
mysql_select_db("secretDB") or die ("Unable to select database.");
$sql = "SELECT ID,name,address FROM users WHERE username='".$username."' and password='".$password."'";
$result = mysql_query($sql) or die ("Unable to get results.");
$num = mysql_num_rows($result);
if ($num==0)
{?>
<head><title>Login form</title></head>
<body bgcolor="#ffffff"> You're not authorized to be here. If you feel you have recieved this message in error, please contact the <a href="mailto:me@me.net">webmaster</a></body>
<?}else{
echo "<p>You can be here<br>";
echo "Your username is $username</p>";
$sql_new="insert into new_db (id, name, address) values ('".mysql_result($result,0,"id")."', '".mysql_result($result,0,"name")."', '".mysql_result($result,0,"address")."');
mysql_query ( $sql_new ) or die ( " can not insert into new_db ");
}
}
?>