I’ve added a simple pm system on to my localhost recently and while I can send messages successfully, I can’t receive them and new messages don’t show up in the inbox.
inbox.php
[php]
- ';
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 '' . $row['message_title'] .
'(New)
'; }else{ echo '' . $row['message_title'] . '
'; }} echo '
new_message.php
[php]<?php
include(‘date.php’);
include(‘config.php’);
$userfinal = $_SESSION[‘id’];
$user = $userfinal;
?>
<form name="message" action="messageck.php"method=“post”>
Title:
To:
Message:
'; ?>
[/php]
messageck.php
[php]<?php
include(‘date.php’);
include(‘config.php’);
$title = $_POST[‘message_title’];
$to = $_POST[‘message_to’];
$content = $_POST[‘message_content’];
$from = $_POST[‘message_from’];
$time = $_POST[‘message_date’];
$ck_reciever = “SELECT username FROM users WHERE username = '”.$to."’";
if( mysql_num_rows( mysql_query( $ck_reciever ) ) == 0 ){
die("The user you are trying to contact doesn’t exist. Please go back and try again.
method=“post”>
<input type=“submit” value=“Try Again”>
");
}
elseif(strlen($content) < 1){
die("You can’t send an empty message!
method=“post”>
<input type=“submit” value=“Try Again”>
");
}
elseif(strlen($title) < 1){
die("You must have a Title!
method=“post”>
<input type=“submit” value=“Try Again”>
");
}else{
@mysql_query(“INSERT INTO messages (from_user, to_user, message_title, message_contents,
message_date) VALUES (’$from’,’$to’,’$title’,’$content’,’$time’)” OR die(‘Could not send the message’).mysql_error());
echo “The Message Was Successfully Sent!”;
?>
<form name="back" action="inbox.php"method=“post”>
<?php } ?>[/php]read_message.php
[php]<?php
include(‘date.php’);
include(‘config.php’);
$userfinal = $_SESSION[‘id’];
$messageid = $_GET[‘message’];
$message = mysql_query(“SELECT * FROM messages WHERE message_id = ‘$messageid’ AND
to_user = ‘$userfinal’”);
$message = mysql_fetch_assoc($message);
echo “
Title:
“.$message[‘message_title’].”
”;
echo “
From:
“.$message[‘from_user’].”
”;
echo “
Message:
“.$message[‘message_contents’].”
”;
echo ‘’;
echo ‘’;
echo ‘’;
?>[/php]
Any insight on to why this isn’t working would be appreciated!