<?
include("functions/conexion.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Register</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="css/style.css" media="screen" />
</head>

<body>
	<div id="title">
	<div id="header">
	<img src="images/money.png" alt="Money" align="left"/>
	</div>
	<div id="virtualtrade">
	<h1>      
    	<a href="index.php"><img src="images/title.png" alt="Virtual Trade"/></a>
    </h1>
	</div>
	<div id="signin">
	<?
	if(isset($_SESSION['login'])) {
		echo "<a href='/infouser.php'>".$_SESSION['login']."</a>";
		echo "&nbsp;&nbsp;";
		echo "<a href='/functions/logout.php'>Sign out</a>";
	}
	else{
	?>
	<a href="/register.php">Register</a>
	<a href="/loginindex.php">Sign in</a>
	<?
	}
	?>
	<br/>
	</div>
</div>
<div id="register">
<script type="text/javascript">
function check()
{
 if(document.forms["register"].login.value == "")
 {
 	alert("Write your login");
	document.forms["register"].login.focus();
	return false;
	}
	else if(document.forms["register"].password.value == "")
	{
	 alert("Write your password");
	 document.forms["register"].password.focus();
	 return false;
	}
	else if(document.forms["register"].name.value = "")
	{
	 alert("Write your name");
	 document.forms["register"].name.focus();
	 return false;
	}
	else if(document.forms["register"].address.value = "")
	{
	 alert("Write your address");
	 document.forms["register"].address.focus();
	 return false;
	}
	else if(parseInt(document.forms["register"].age.value = ""))
	{
	 alert("Write your age");
	 document.forms["register"].age.focus();
	 return false;
	}
	else
	{
	 return true;
	}
}
</script>
<form name="register" method="post" action="register2.php">
<table id="register">
<tr>
<td align="left">Login: </td><td><input type="text" name="login" /></td>
</tr>
<tr>
<td align="left">Password:</td><td><input type="password" name="password" /></td>
</tr>
<tr>
<td align="left">Name:</td><td><input type="text" name="name" /></td>
</tr>
<tr>
<td align="left">Address:</td><td><input type="text" name="address" /></td>
</tr>
<tr>
<td align="left">Age:</td><td><input type="text" name="age" /></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Register" onClick="return check()"/>
</tr>
</table>
<input type="hidden" name="ownerid" value="<? echo $ownerid; ?>"/>
<input type="hidden" name="stock" value="<? echo $stock; ?>"/>
</form>
<?
if(isset($_GET["message"])){
	echo $_GET["message"];
}
?>
<a href="index.php">Back to index</a>
</div>
</body>
</html>
