<?
include_once "ebayfunctions.php";
if($_POST['register'])
{
header("location:ebayregistration.php");
}
connect();
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"";
echo "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"eng\" xml:lang=\"en\">";
echo "<head>";
echo "<meta http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\" />";
echo "<title>Register</title>";
echo "<link rel=\"stylesheet\" href=\"../hornet.css\" type=\"text/css\" />";
echo "</head>";
echo "<p>";
echo "<em><a href=\"../index.html\">HornetTrade.com</a></em>";
echo "</p>";
if(!$POST['login'] && !$POST['register'] )
{
echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n";
echo "<form method=\"post\" action=\"ebaylogin.php\">\n";
echo "<tr><td colspan=\"2\" align=\"center\">Login</td></tr>\n";
echo "<tr><td>UserName</td><td><input type=\"text\" name=\"username\"></td></tr>\n";
echo "<tr><td>Password</td><td><input type=\"password\" name=\"password\"></td></tr>\n";
echo "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" name=\"login\" value=\"Login\">\t\t\t<input type=\"submit\" name=\"register\" value=\"Register\"></td></tr>\n";
echo "</form></table>\n";
}else
{
$username = protect($POST['username']);
$password = protect($POST['password']);
$errors = array();
if(!$username)
{
$errors[] = "Username is not defined!";
}
if($username)
{
$range = range(1,32);
if(!in_array(strlen($username), $range))
{
$errors[] = "Username must be between 1 and 32 characters long";
}
}
if(!$password)
{
$errors[] = "Password is not defined!";
}
if($password)
{
$range2 = range(1,50);
if(!in_array(strlen($password), $range2))
{
$errors[] = "Password must be between 1 and 50 characters long";
}
}
if(count($errors) > 0)
{
foreach($errors AS $error)
{
echo $error . "<br>\n";
}
}else
{
if($username && $password)
{
$sql = "SELECT * FROM `user` WHERE `Username`='$username' AND `Password`='$password'";
$res = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($res) > 0)
{
header("location:index.php");
}else
{
echo "User Name or Password is incorrect";
}
}
}
}
?>
This is my code. I have it set so that if neither buttons are pressed then show the HTML for the login page. I dont see how i can do the header first because it requires some database stuff to decide on which page to goto.