0

here is my code for read message but error display in my page

Notice: Undefined index: message in C:\wamp\www\.....m\Mailbox\read_message.php on line 6

anyone help me for this problem.how to solve it.

CREATE TABLE `messages` (
  `message_id` int(11) NOT NULL auto_increment,
  `from_user` varchar(65) character set latin1 collate latin1_general_ci NOT NULL,
  `to_user` varchar(65) character set latin1 collate latin1_general_ci NOT NULL,
  `message_title` varchar(65) NOT NULL,
  `message_contents` longtext NOT NULL,
  `message_read` int(11) NOT NULL default '0',
  PRIMARY KEY  (`message_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=21;
<?php
session_start();
$userfinal=$_SESSION['MM_Username'];
require "database.php";

$message_id = $_GET['message'];
$message = mysql_query("SELECT * FROM messages WHERE message_id = '$message_id' AND to_user = '$userfinal'");
$message_id=mysql_fetch_assoc($message);

echo "<h1>Title: ".$message['message_title']."</h1><br><br>";
echo "<h3>From: ".$message['from_user']."<br><br></h3>";
echo "<h3>Message: <br>".$message['message_contents']."<br></h3>";

echo '<form name="backfrm" method="post" action="inbox.php">';
 echo '<input type="submit" value="Back to Inbox">';
 echo '</form>';
?>
3
Contributors
7
Replies
8
Views
6 Years
Discussion Span
Last Post by urtrivedi
0
$_GET['message']

this variable is empty. check the spelling in the previous page from where your current page is called.

0
$_GET['message']

this variable is empty. check the spelling in the previous page from where your current page is called.

its previous page .

<?php
session_start();
require "database.php";
$userfinal=$_SESSION['MM_Username'];

// get the messages from the table.
$get_messages = mysql_query("SELECT message_id FROM messages WHERE to_user='$userfinal' ORDER BY message_id DESC") or die(mysql_error());
$get_messages2 = mysql_query("SELECT * FROM messages WHERE to_user='$userfinal' ORDER BY message_id DESC") or die(mysql_error());
$num_messages = mysql_num_rows($get_messages);
// display each message title, with a link to their content
echo '<ul>';
for($count = 1; $count <= $num_messages; $count++)
{

    $row = mysql_fetch_array($get_messages2);
    //if the message is not read, show "(new)" after the title, else, just show the title.
if($row['message_read'] == 0)
{
    echo '<a href="read_message.php?messageid=' . $row['message_id'] . '">' . $row['message_title'] . '</a>(New)<br>';
}else{
echo '<a href="read_message.php?messageid=' . $row['message_id'] . '">' . $row['message_title'] . '</a><br>';
}}
echo '</ul>';
echo '<form name="newmsgfrm" method="post" action="new_message.php">';
echo '<input type="submit" value="Send a New Message">';
echo '</form>';

echo '<form name="backfrm" method="post" action="index.php">';
echo '<input type="submit" value="Back to Home">';
echo '</form>';
?>
0

in your read message page you must use

$_GET['messageid']

see line 20 and 22 of your above code

Edited by urtrivedi: n/a

0

thanks for helping.

can you guide me for how can i insert image in my message box and i want to reply system in my script.

in your read message page you must use

$_GET['messageid']

see line 20 and 22 of your above code

0

i m not sure what are you asking but in your line no 13 of your topmost post, You can add img tag.

echo "<h3>Message: <br><img src='error.jpg' border=0>".$message['message_contents']."<br></h3>";

Edited by urtrivedi: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.