<?php session_start(); 
$previous = $_SESSION['previous'];
$_SESSION['previous'] = "sell.php";
echo $previous.'<br>';

if( !isset($_SESSION['userid']))
{  echo "username is not set <br>";
}
else
{  echo "username is set : ".$_SESSION['userid']."<br>";	
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Transaction Status</title>

<script type="text/javascript">
function validate(form)
{
form.submit()
}

function re(form1)
{ 
  if(confirm("Do you want to reset the form"))
  {
  }   
}
</script>

<?php 
$connect = mysql_connect("localhost","root","programming");
if (!$connect)
{ die('Could not connect: '.mysql_error());  }
mysql_select_db("BOOK_DB", $connect);


$query = "SELECT ISBN as isbn from BOOK;";
$result = mysql_query($query);

echo'
<form id="form1" name="form1" method="post" action="sell_submit.php">

	  <br><br>
	  SELECT ISBN : 
	  <select name="isbn">';
	  
	  while( $row = mysql_fetch_array($result))
	  {
	  echo sprintf("<option value='%s'>'%s'</option>",$row['isbn'],$row['isbn']);
      }
      
echo '
	  </select>
	  
	  <br><br>
	  <label>Selling Price 
	  <input type="text" name="sp" id="sp" />
	  </label>
	  <br>
	  
	  <br>
	  Book Type:
	  <table>
		<tr> 
			<td> <label> USED </label><input type="radio" name="stype" value="use" /> </label> </td>
			<td> <label> NEW <input type="radio" name="stype" value="new" CHECKED /> </label> </td>
		</tr>
	  </table>
	  
	  <br>
	  <label>Number of Copies
	  <input type="text" name="num" id="num" />
	  </label>
	  
	  <p>
		<input type="submit" onClick="validate(this.form)" name="button" id="button" value="Submit" />
		<input name="b" type="button" onClick="re(this.form)" id="b" value="Clear" />
	  </p>
	  
</form>';
?>
</body> 
</html>
