<? 
session_start();
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>Buy</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="buyuser">
<h2>Buy</h2>
<?
$query = "SELECT * FROM Stock";
$answer = mysql_query($query, $conexion);
?>

<form name="formBuy" method="post" action="functions/buyinyourchoice.php">
<table id="buyuser">
<tr>
<td colspan="2" align="center"><h4>Buy</h4></td>
</tr>
<tr>
<td align="left">Ticker: </td><td><SELECT NAME="ticker">
<?
while($row = mysql_fetch_array($answer)){
echo "<OPTION value='".$row["id"]."'>".$row["ticker"]."</option>";
}
?>
</SELECT></td>
</tr>
<tr>
<td align="left">Volume: </td><td><input type="text" name="volume" /></td>
</tr>
<tr>
<td align="left">Price: </td><td><input type="text" name="price" /></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Send" onClick="return validar()"/></td>
</tr>
</table>
</form>
</div>
</body>
</html>
