How to attach file with personal message system
Posted: Sun Dec 06, 2009 7:33 pm
HI Friends,
I need your help to code for my personal message system .
I am working on a social networking website .
I have created a Personal message system .
Through that i can compose message , reply message ,
Read messages , And delete the message as well .
But i have a trouble with the attachment of my new message or my reply message .
I have tried to google it , and i came accross attaching files
but most of them have used the mail . I am not suing the mail function
as it is a simple message system . So it is just a common database for inbox and user .
So please guise me for my this task .
My files are as under :
inbox.php
<?php
session_start();
$userfinal=$_SESSION['user_id'];
echo"
<div align='center'><a href='logout.php'><strong>LOGOUT</strong></a> || <a href='inbox.php'><strong> INBOX</strong></a>
|| <a href='new_message.php'><strong>COMPOSE</strong></a> || <a href='sent.php'><strong> SENT ITEMS</strong> </a></div> " ;
echo" <div align='right'> Hi <strong> $userfinal </strong> </div> " ;
require "global.inc.php";
if (isset($_GET[delete]))
{
$messageid = $_GET[delete];
// mysql_query("DELETE FROM mailbox WHERE Messageid='$messageid' ");
mysql_query("UPDATE mailbox set Rec_del='0' WHERE Messageid='$messageid'");
}
// get the messages from the table.
$get_messages = mysql_query("SELECT Messageid FROM mailbox WHERE Receiver='$userfinal' ORDER BY Messageid DESC") or die(mysql_error());
$get_messages2 = mysql_query("SELECT * FROM mailbox WHERE Receiver='$userfinal' ORDER BY Messageid DESC") or die(mysql_error());
$num_messages = mysql_num_rows($get_messages);
// display each message title, with a link to their content
//echo session_name();
/// just for count
echo "<strong> Please click on the link to see detailed message .</strong>";
echo '<ul>';
for($count = 0; $count <= $num_messages; $count++)
{
static $count=0;
$row = mysql_fetch_array($get_messages2);
if($row['Rec_del']==1)
{
//if the message is not read, show "(new)" after the title, else, just show the title.
if($row['Status'] == 0)
{
echo '<a href="read_message.php?messageid=' . $row['Messageid'] . '">' . $row['Subject'] .'</a> <br>';
$count++;
?>
<div align="right"> <?php echo "".$row['Time']; ?> </div>
<?php }
else
{
echo '<a href="read_message.php?messageid=' . $row['Messageid'] . '">' . $row['Subject'] . '</a> <br>'; ?>
<div align="right"> <?php echo "".$row['Time'];?> </div>
<?php $count++;
}
}
}
// delete all rec_del & sent_del = 0 !!!
mysql_query("DELETE FROM mailbox WHERE Rec_del='0' AND Sent_del='0' ");
?>
read_mesage.php
<?php
session_start();
$userfinal=$_SESSION['user_id'];
require "global.inc.php";
echo"
<div align='center'><a href='logout.php'><strong>LOGOUT</strong></a> || <a href='inbox.php'><strong> INBOX</strong></a>
|| <a href='new_message.php'><strong>COMPOSE</strong></a> || <a href='sent.php'><strong> SENT ITEMS</strong> </a></div> " ;
echo" <div align='right'> Hi <strong> $userfinal </strong> </div> " ;
$messageid = $_REQUEST['messageid'];
$message = mysql_query("SELECT * FROM mailbox WHERE Messageid = '$messageid' AND Receiver = '$userfinal'");
$message=mysql_fetch_assoc($message);
$q="UPDATE mailbox SET Status='1' WHERE Messageid = '$messageid' AND Receiver = '$userfinal'";
mysql_query($q);
$Sender=$message['Sender'];
echo "Title: ".$message['Subject']."<br><br>"; ?>
<div align="right"><?php echo " ".$message['Time']; ?></div>
<?php
echo "From: ".$message['Sender']."<br><br></h3>";
echo "Message: <br>".$message['Body']."<br>";
?>
<p></p><p></p><p></p>
<div align="center">
Please click here to delete this message :-
<?php echo "<a href='inbox.php?delete=".$messageid ."'><strong>Delete</strong></a>";?>
</div>
<p>
<div align="center">
Please click here to reply this message :-
<?php echo "<a href='inbox_reply.php?sender=".$Sender."'><strong>Reply</strong></a>";?>
</div>
</p>
new_inbox.php
<?php
session_start();
$userfinal=$_SESSION['user_id'];
$user=$userfinal;
echo"
<div align='center'><a href='logout.php'><strong>LOGOUT</strong></a> || <a href='inbox.php'><strong> INBOX</strong></a>
|| <a href='new_message.php'><strong>COMPOSE</strong></a> || <a href='sent.php'><strong> SENT ITEMS</strong> </a></div> " ;
echo" <div align='right'> Hi <strong> $userfinal </strong> </div> " ;
require "global.inc.php";
?>
<form name="message" action="messageck.php" method="post">
Title :<input type="text" name="message_title"> <br>
From : <?php echo $user; ?> <br>
To :<input type="text" name="message_to"> <br>
Message: <br>
<textarea rows="10" cols="50" name="message_content"></textarea>
<?php
echo '<input type="hidden" name="message_from" value="'.$user.'"><br>';
?>
<input type="submit" value="Submit">
</form>
inbox_reply.php
<?php
session_start();
$userfinal=$_SESSION['user_id'];
$user=$userfinal;
$sender=$_REQUEST['sender'];
echo"
<div align='center'><a href='logout.php'><strong>LOGOUT</strong></a> || <a href='inbox.php'><strong> INBOX</strong></a>
|| <a href='new_message.php'><strong>COMPOSE</strong></a> || <a href='sent.php'><strong> SENT ITEMS</strong> </a></div> " ;
echo" <div align='right'> Hi <strong> $userfinal </strong> </div> " ;
require "global.inc.php";
?>
<form name="message" action="messageck.php" method="post">
Title :<input type="text" name="message_title"> <br>
From : <?php echo $user; ?> <br>
To :<input type="text" name="message_to" value="<?php echo $sender; ?>"> <br>
Message: <br>
<textarea rows="10" cols="50" name="message_content"></textarea>
<?php
echo '<input type="hidden" name="message_from" value="'.$user.'"><br>';
?>
<input type="submit" value="Submit">
</form>
PLSSSSSSSSS help me with this friends !!
Thanks in advance !!
I need your help to code for my personal message system .
I am working on a social networking website .
I have created a Personal message system .
Through that i can compose message , reply message ,
Read messages , And delete the message as well .
But i have a trouble with the attachment of my new message or my reply message .
I have tried to google it , and i came accross attaching files
but most of them have used the mail . I am not suing the mail function
as it is a simple message system . So it is just a common database for inbox and user .
So please guise me for my this task .
My files are as under :
inbox.php
<?php
session_start();
$userfinal=$_SESSION['user_id'];
echo"
<div align='center'><a href='logout.php'><strong>LOGOUT</strong></a> || <a href='inbox.php'><strong> INBOX</strong></a>
|| <a href='new_message.php'><strong>COMPOSE</strong></a> || <a href='sent.php'><strong> SENT ITEMS</strong> </a></div> " ;
echo" <div align='right'> Hi <strong> $userfinal </strong> </div> " ;
require "global.inc.php";
if (isset($_GET[delete]))
{
$messageid = $_GET[delete];
// mysql_query("DELETE FROM mailbox WHERE Messageid='$messageid' ");
mysql_query("UPDATE mailbox set Rec_del='0' WHERE Messageid='$messageid'");
}
// get the messages from the table.
$get_messages = mysql_query("SELECT Messageid FROM mailbox WHERE Receiver='$userfinal' ORDER BY Messageid DESC") or die(mysql_error());
$get_messages2 = mysql_query("SELECT * FROM mailbox WHERE Receiver='$userfinal' ORDER BY Messageid DESC") or die(mysql_error());
$num_messages = mysql_num_rows($get_messages);
// display each message title, with a link to their content
//echo session_name();
/// just for count
echo "<strong> Please click on the link to see detailed message .</strong>";
echo '<ul>';
for($count = 0; $count <= $num_messages; $count++)
{
static $count=0;
$row = mysql_fetch_array($get_messages2);
if($row['Rec_del']==1)
{
//if the message is not read, show "(new)" after the title, else, just show the title.
if($row['Status'] == 0)
{
echo '<a href="read_message.php?messageid=' . $row['Messageid'] . '">' . $row['Subject'] .'</a> <br>';
$count++;
?>
<div align="right"> <?php echo "".$row['Time']; ?> </div>
<?php }
else
{
echo '<a href="read_message.php?messageid=' . $row['Messageid'] . '">' . $row['Subject'] . '</a> <br>'; ?>
<div align="right"> <?php echo "".$row['Time'];?> </div>
<?php $count++;
}
}
}
// delete all rec_del & sent_del = 0 !!!
mysql_query("DELETE FROM mailbox WHERE Rec_del='0' AND Sent_del='0' ");
?>
read_mesage.php
<?php
session_start();
$userfinal=$_SESSION['user_id'];
require "global.inc.php";
echo"
<div align='center'><a href='logout.php'><strong>LOGOUT</strong></a> || <a href='inbox.php'><strong> INBOX</strong></a>
|| <a href='new_message.php'><strong>COMPOSE</strong></a> || <a href='sent.php'><strong> SENT ITEMS</strong> </a></div> " ;
echo" <div align='right'> Hi <strong> $userfinal </strong> </div> " ;
$messageid = $_REQUEST['messageid'];
$message = mysql_query("SELECT * FROM mailbox WHERE Messageid = '$messageid' AND Receiver = '$userfinal'");
$message=mysql_fetch_assoc($message);
$q="UPDATE mailbox SET Status='1' WHERE Messageid = '$messageid' AND Receiver = '$userfinal'";
mysql_query($q);
$Sender=$message['Sender'];
echo "Title: ".$message['Subject']."<br><br>"; ?>
<div align="right"><?php echo " ".$message['Time']; ?></div>
<?php
echo "From: ".$message['Sender']."<br><br></h3>";
echo "Message: <br>".$message['Body']."<br>";
?>
<p></p><p></p><p></p>
<div align="center">
Please click here to delete this message :-
<?php echo "<a href='inbox.php?delete=".$messageid ."'><strong>Delete</strong></a>";?>
</div>
<p>
<div align="center">
Please click here to reply this message :-
<?php echo "<a href='inbox_reply.php?sender=".$Sender."'><strong>Reply</strong></a>";?>
</div>
</p>
new_inbox.php
<?php
session_start();
$userfinal=$_SESSION['user_id'];
$user=$userfinal;
echo"
<div align='center'><a href='logout.php'><strong>LOGOUT</strong></a> || <a href='inbox.php'><strong> INBOX</strong></a>
|| <a href='new_message.php'><strong>COMPOSE</strong></a> || <a href='sent.php'><strong> SENT ITEMS</strong> </a></div> " ;
echo" <div align='right'> Hi <strong> $userfinal </strong> </div> " ;
require "global.inc.php";
?>
<form name="message" action="messageck.php" method="post">
Title :<input type="text" name="message_title"> <br>
From : <?php echo $user; ?> <br>
To :<input type="text" name="message_to"> <br>
Message: <br>
<textarea rows="10" cols="50" name="message_content"></textarea>
<?php
echo '<input type="hidden" name="message_from" value="'.$user.'"><br>';
?>
<input type="submit" value="Submit">
</form>
inbox_reply.php
<?php
session_start();
$userfinal=$_SESSION['user_id'];
$user=$userfinal;
$sender=$_REQUEST['sender'];
echo"
<div align='center'><a href='logout.php'><strong>LOGOUT</strong></a> || <a href='inbox.php'><strong> INBOX</strong></a>
|| <a href='new_message.php'><strong>COMPOSE</strong></a> || <a href='sent.php'><strong> SENT ITEMS</strong> </a></div> " ;
echo" <div align='right'> Hi <strong> $userfinal </strong> </div> " ;
require "global.inc.php";
?>
<form name="message" action="messageck.php" method="post">
Title :<input type="text" name="message_title"> <br>
From : <?php echo $user; ?> <br>
To :<input type="text" name="message_to" value="<?php echo $sender; ?>"> <br>
Message: <br>
<textarea rows="10" cols="50" name="message_content"></textarea>
<?php
echo '<input type="hidden" name="message_from" value="'.$user.'"><br>';
?>
<input type="submit" value="Submit">
</form>
PLSSSSSSSSS help me with this friends !!
Thanks in advance !!