<?php
$username = empty($_POST['username']) ? '' : $_POST['username'];
$password = empty($_POST['password']) ? '' : $_POST['password'];
$myhost = "my database host";
$myuser = "my username";
$mypsw = "my password";
$mydb = "my database name";
$dblink = mysql_connect($myhost, $myuser, $mypsw) or die("Error: cannot connect");
$db_selected = mysql_select_db($mydb, $dblink) or die("Error: cannot select db");
$query1 = "select S.sid from Sailors S where S.username = '".$username."' and S.password = '".$password."';";
if (mysql_num_rows($query1, $dblink) != 0)
{
setcookie('username', $username);
header("Location: main.php");
}
?>