
<?php 
session_start();
 if(!isset($_SESSION['email']))
  { $_SESSION['email'] = $_POST[email]; }
if(!isset($_SESSION['password'])) 
{ $_SESSION['password'] = $_POST[password]; } ?>
<html>
<head>
<title>The Science Network</title>

<link rel="stylesheet" type="text/css" href="style.css" />
</head>
	<body style="background-color:#E8E8E8">
    	<?php
		

$db = mysql_connect("localhost","root","mysql");           /* start connection with database */

echo "<br>";
if (!$db)                                                       /* conditional statement */
{
die('Connection to Database down: '. mysql_error());            /* print if connection is not established */
}

mysql_select_db("ScientistNet", $db); 

$sql =mysql_query("SELECT email , id
FROM Scientist "
) 
                     or die(mysql_error());
					 
  $midf=$_POST['midf']; //if its forward this will have a value else if compose it will be null
  
  if($midf != null)
  {
  $sqlm =mysql_query("SELECT subject ,body
FROM Mail 
WHERE id=$midf"
) 

or die(mysql_error());

$mail = mysql_fetch_assoc($sqlm);	
  }
  
  					 
  $midr=$_POST['midr'];  //if its reply this will have a value else if compose it will be null
    if($midr != null)
  {
  $sqlmr =mysql_query("SELECT subject ,body , sender
FROM Mail 
WHERE id=$midr"
) 

or die(mysql_error());

$mail = mysql_fetch_assoc($sqlmr);	

$sender= $mail['sender'];
  }
  

?>                     
    	<center>
    	<table width="768" height="519" border="0" style="background-color:#666666;">
  <tr>
    <td colspan="2"><img src="./logo2.gif" width="763" height="108" alt="logo"></td>
    </tr>
   <tr>
    <td colspan="2" valign="middle" style="background-color:#666;">
       
    </td>
    </tr>
   <tr>
    <td  width="585" height="379"  class="sidebar" style="background-color:#FFF; vertical-align:top; text-align:left">		        <br />
   	 <!--<form method="POST" 
action="sending.php" enctype="multipart/form-data">-->
   <form action="./sending.php" method="post">
  <label for='email'>To  :</label> 
  <!--<select name="to">-->
  <?php
  
//while($to = mysql_fetch_array( $sql)) // choose email from drop list
//{
	$toemail= $to['email'];
	$toid = $to['id'];
	if($sender == $toid)
	//echo "<option value='$toid' selected='selected'> $toemail </option>";
	echo "<input type='text' name='email' value='$toemail'><br><br />";
	else
    //echo "<option value='$toid'> $toemail </option>";
	echo "<input type='text' name='email' value='$toemail'><br><br />";
//}
	
	?>
    
  </select>
  <br><br />
  <label for='subject'>Subject: </label>
<?php 
if($midf != null)

{ 
$sub =  "FW:".$mail['subject'];
}

if($midr != null)
{ 
$sub =  "RE:".$mail['subject'];
}
echo "<input type='text' name='subject' value='$sub'><br><br />";
?>
  <label for='body'>Body:</label>
 <br> 
 <?php  
$body =  $mail['body'];

/* To replay the meesage*/
if($midr != null || $midf!= null)
{
echo "<textarea name='body' value='$body' rows='15' cols='50'> 

&nbsp
-------Original Message---------
 &nbsp
 $body</textarea><br><br />";

}
else
echo "<textarea name='body' rows='15' cols='50'> </textarea><br><br />";


?>
<label for='uploaded_file'>Attachments</label><br /><br />
<input type="file" name="file" id="file" /> 
<input type="submit" value="Submit" name='submit'>
<input type="reset" value="Reset" name='reset'><br />
</form>

<html>
<body>




</body>
</html>
     
    </td>
    <td width="173" align="center" valign="middle" class="sidebar" style="background-color:#CCC">
	
	<a href="./mail.php">Close</a>

    </td>
  </tr>
  <tr>
    <td colspan="2" align="center" valign="middle" style="background-color:#666; color:#FFF;">The Science Network, 2012&copy;</td>
    </tr>
</table>

	</body>
</html>