So the user clicks on the email link and it gives them the following options
Inbox
Outbox
Compose
When you go to inbox you get a list of all of inbox message you then have an option to view it. When you click "View" you go to "inbox.php" Which displays the message and gives a you a form that lets you reply (the original code i provided.)
Here is inbox.php in its entire form
<?php
//This code checks to make sure they are logged in BEFORE they can access the webpage
session_start();
if(!isset($_SESSION['myusername'])){
//If he is not logged in, go to index.php
header("location:/si/onikz/index.php");
}else{
//If he is logged in do nothing and go on to the rest of the code.
}
?>
<!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=iso-8859-1" />
<title>Email: Inbox</title>
<link rel="stylesheet" href="http://onikz.com/si/housekeeping/css.css" type="text/css" media="screen" />
<body>
<div id="content">
<div id="email">
<?php
$id=$_GET['id'];
inbox($id); //Calls the inbox function
?>
</div>
</div>
<?php
//This adds the menu to the program
include("../housekeeping/menu.html");
?>
</body>
</html>
<?php
function inbox($id){
//THIS CODE JUST SHOWS THE BUTTONS
//They are disquised as links with a button exterior
echo "<center><form mehtod=\"get\"><input type=\"submit\" value=\"Inbox\" name=\"inbox\" />";
echo "<input type=\"submit\" value=\"Outbox\" name=\"outbox\" />";
echo "<input type=\"submit\" value=\"Compose\" name=\"compose\" />";
if(isset($_GET["inbox"])){
echo "<meta http-equiv=\"Refresh\" content=\"1; URL=http://onikz.com/si/email/index.php?inbox=Inbox\">";
}
if(isset($_GET["outbox"])){
echo "<meta http-equiv=\"Refresh\" content=\"1; URL=http://onikz.com/si/email/index.php?outbox=Outbox\">";
}
if(isset($_GET["compose"])){
echo "<meta http-equiv=\"Refresh\" content=\"1; URL=http://onikz.com/si/email/index.php?compose=Compose\">";
}
//THIS IS THE CODE THAT DISPLAYS THE MESSAGE.
include("../housekeeping/dbconnect.php"); //conects to database
$username=$_SESSION["myusername"]; //assigns the user name to $username
$sql ="SELECT * FROM `SocInt`.`email` WHERE `id`='$id'"; //This selects the message fromt he database
$result=mysql_query($sql);
$count=1;
while($row = mysql_fetch_array($result)){ //This While Function displays the message
$to = $row[to];
$from=$row[from];
$subject=$row[subject];
$message=$row[message];
$id=$row[id];
if($to == $username){ //This double checks to make sure the username also
//matches
echo"<center><table id=\"emailInbox\" width=\"500px;\">";
echo"<tr id=\"emailInbox\" width=\"500px;\"><td id=\"emailInbox\" width=\"100px;\">From:</td><td id=\"emailInbox\" width=\"400px\"><i>$from</i></td></tr>";
echo "<tr id=\"emailInbox\" width=\"500px;\"><td id=\"emailInbox\" width=\"100px;\">Subject</td><td id=\"emailInbox\" width=\"400px\"><b>$subject</b></td></tr>";
echo "<tr id=\"emailInbox\" width=\"500px;\"><td id=\"emailInbox\" width=\"100px;\">Message</td><td id=\"emailInbox\" width=\"400px\"><b>$message</b></td></tr>";
echo"</table>";
echo "<a href=\"http://onikz.com/si/email/delete.php?id=$id&&con=0\">Delete this message</a>";
echo "<br /><br />-------------------Reply-----------------------<br /><br />";
echo "<center><h3>The REPLY option just crashed. It will not work. <a href=\"http://onikz.com/si/email/index.php?compose=Compose\"> Compose</a>still works</h3></center>";
$from=$to;
//The below code displays the option to reply to the message
//This is a modified version of the code in index.php?compose=Compose
echo "<table>";
echo "<form action=\"sendmail.php\" method=\"post\" name=\"email\">";
echo "<tr>";
echo " <td>To:</td>";
echo "<td><input name=\"to\" type=\"text\" size=\"50\" maxlength=\"70\" value=\"$to\"/></td>";
echo " </tr>";
echo " <tr>";
echo " <td>Subject</td>";
echo " <td><input name=\"Subject\" type=\"text\" size=\"50\" maxlength=\"70\" value=\"RE: $subject\"/><br /></td>";
echo " </tr>";
echo " <tr>";
echo " <td>Message</td>";
echo " <td><textarea name=\"Message\" cols=\"50\" rows=\"5\">\n\n---Original Message Sent By $from---</textarea></td>";
echo " </tr>";
echo " <tr>";
echo " <td>Options</td>";
echo " <td><input name=\"send\" type=\"submit\" value=\"Send\" src=\"sendmail.php\"/></form></td>";
echo " </tr>";
echo " </table>";
echo"</center>";
}
}
}
?>
Well when the user finally fills out the reply form they take the message and sends it to sendmail.php, and here it is.
<?php
//This code checks to make sure they are logged in BEFORE they can access the webpage
session_start();
if(!isset($_SESSION['myusername'])){
//If he is not logged in, go to index.php
header("location:/si/onikz/index.php");
}else{
//If he is logged in do nothing and go on to the rest of the code.
}
include("../housekeeping/dbconnect.php");
$to = $_POST['to'];
$from = $_SESSION['myusername'];
$subject= $_POST['Subject'];
$message= $_POST['Message'];
$today=date('F j, Y h:i');
$results="INSERT INTO `SocInt`.`email` (
`id` ,
`to` ,
`from` ,
`subject` ,
`message`,
`date`
)
VALUES (
NULL, '$to', '$from', '$subject', '$message', NOW()
);";
if(mysql_query($results))
{
echo"<center>";
echo"Your message was successful!<br/>";
echo "<meta http-equiv=\"Refresh\" content=\"1; URL=http://onikz.com/si/email/index.php?inbox=Inbox\">";
echo "<a href=\"http://onikz.com/si/email/index.php?inbox=Inbox\">Click here if you are not automatically redirected</a>";
echo"</center>";
}else{echo"Sorry, an error occured, please contact the administrator or try again." . mysql_error();}
?>
BUT, the form NEVER gets to sendmail.php...it never goes to another page. the problem is, when you click submit the page does nothing...
if you would like to check this out first hand just email me and ill give you a test username and password so you can see EXACTLY what it is doing.
MY EMAIL IS... strujillo.jr (AT) GMAIL.COM