Jump to content

Need help with my Internal Mail Script


Accurax

Recommended Posts

ok guys, ive got a mail script for internal messaging that im trying to deploy. Ive got to the point where the message is successfully sent to the recipient, and the recipient can see the message title in there inbox, no problem.

However i cant figure out how to get the message body displayed when the user clicks on the message title link.

Heres the code that is responsible for displaying the message body.

[code]
if($action==inbox) {
$result=mysql_query("SELECT * FROM mail WHERE UserTo='$username' ORDER BY SentDate DESC") or die ("cant do it");
echo "<table cellpadding=2 cellspacing=1 width=500 valign=top>";
while ($row=mysql_fetch_array($result)) {

echo "<tr><td width=30>Mail:</td><td><a href=mail.php?view=veiw&mail_id=$row[mail_id]>$row[Subject]</a></td>

<td width=50> <a href=mail.php?action=delete&id=$row[mail_id]><center>Delete</a><br></td></tr>";

}
echo "</table>";
}
$view = $_GET['view'];
if($view==view) {
$result=mysql_query("SELECT * FROM mail WHERE UserTo='$username' AND mail_id=$mail_id") or die ("cant do it");
$row=mysql_fetch_array($result);
if($row[UserTo]==$username) {
} else {
echo "<font face=verdana><b>This isn't your mail!";
exit;
}[/code]

I have a feeling that this line of code is the culptit

[code]
echo "<tr><td width=30>Mail:</td><td><a href=mail.php?view=veiw&mail_id=$row[mail_id]>$row[Subject]</a></td>
[/code]

Bust im not sure what to do with it... any tips?
Link to comment
https://forums.phpfreaks.com/topic/30365-need-help-with-my-internal-mail-script/
Share on other sites

[code]
$mailid=$row[mail_id];
$mailsubject=$row[Subject];
echo "<tr><td width=30>Mail:</td><td><a href=mail.php?view=veiw&mail_id=$mailid>$mailsubject</a></td>
[/code]


try that.  I dont think you can use arrays in a url like that.
This is what i have so far...... everything seems to work [b]except for[/b] the bit that actually displays the message and deletes it.

The inbox displays the correct messages, but when you try to access the acual message by clicking on the subject link... it does nothing... no errors.... nothing, just seems to refresh the page.

Heres the complete code, can anyone see what silly silly thing im doing wrong here?

[code]
<?php
session_start();
include("include.inc");
if ( $_SESSION['login'] != "true" )
{
header("location: hacker.php");
}
else
{
echo "<h1 align='center'>Welcome to your member page "; echo $_SESSION['username']; echo "<br /></h1>";
}

$connection=mysql_connect($host, $user, $passwd)
or die ("Could not connect !");
$db = mysql_select_db($database, $connection)
or die ("Could not connect to Database");

$username = $_SESSION['username'];
$result1=mysql_query("select * from members WHERE user_name='$username'") or die ("cant do it");
$row100 = mysql_fetch_array($result1);

echo '<a href="mail.php?action=compose">Compose</a>'; echo '<br /><a href="mail.php?action=inbox">Inbox</a>';

$action = $_GET['action'];
if($action==compose) {
echo "<form action=mail.php?send=yes method=post>";
echo "<table>";
echo "<tr><td>Subject:</td><td><input type=text name=subject size=20 value=$subject></td></tr>";
echo "<tr><td>To:</td><td><input type=text name=to size=20 value=$to></td></tr>";
echo "<tr><td>Message:</td><td><textarea name='message' cols='50' rows='8'></textarea></td></tr>";
echo "<tr><td><input type='submit' name='Submit' value='Submit' /></td></tr>";
echo "</table>";
echo "</form>";
}
$sent = $_GET['send'];
if($sent==yes) {
$subject = $_POST['subject'];
$to = $_POST['to'];
$message = $_POST['message'];
$date = date('d/m/Y');
 
$query = "INSERT INTO mail (UserTo, UserFrom, Subject, Message, SentDate, status)
VALUES ('$to','$username','$subject','$message','$date','unread')";
$result = mysql_query($query)
or die("A letter could not be sent to $to!");
echo("Message Sent to $to!");

}//works to here so far
if($action==inbox) {
$result=mysql_query("SELECT * FROM mail WHERE UserTo='$username' ORDER BY SentDate DESC") or die ("cant do it");
echo "<table cellpadding=2 cellspacing=1 width=500 valign=top>";

while ($row=mysql_fetch_array($result)) {

echo "<tr><td width=30>Mail:</td><td><a href=mail.php?view=veiw&id=$mail_id>$row[Subject]</a></td>
<td width=50> <a href=mail.php?action=delete&id=$mail_id><center>Delete</a><br></td></tr>";
}
echo "</table>";
}
$view = $_GET['view'];
$id = $GET_['id'];
if($view==view) {
$result=mysql_query("select * from mail where UserTo='$username' and mail_id=$id") or die ("cant do it");
$row=mysql_fetch_array($result);
if($row[UserTo]==$username) {
} else {
echo "<font face=verdana><b>This isn't your mail!";
exit;
}
$query="UPDATE mail SET status='read' WHERE UserTo='$username' AND mail_id='$row[mail_id]'";
$query or die("An error occurred resulting that this message has not been marked read.");
echo "<table border = 1 bordercolor = black width = 50% align=center><tr><td>$row[Subject]</td><td>$row[UserFrom]</td></tr><tr><td colspan='2'>$row[Message]<br><a href=mail.php?action=compose&to=$row[UserFrom]&subject=RE:$row[Subject]>Reply</a></td></tr></table>";
$rs = mysql_query("UPDATE mail SET status='read' WHERE mail_id='$mail_id'");
}
if($action==delete) {
$query = mysql_query("DELETE FROM mail WHERE mail_id='$id' LIMIT 1");
if($query) {
echo "<font face=verdana>Message Deleted.</font>";
} else {
echo "The message wasnt deleted.";
}
}
?>[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.