Reply Messages

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Reply Messages

Post by Epiales »

Okay, I have copied the send message information in order to try and figure out how to make a reply. I have the reply button there, and it shows the form to reply to the user, but the subject isn't the same subject in the field when you hit reply. It's the very first message subject that you have in your inbox. So it's not selecting the subject of the inbox you are wanting to reply to. I tried using some Get commands, which I do believe I will need to get the information from the read mail, but can't get it figured out. Below is the code for reading the message and replying to the message. Any help would be awesome :) Thx!!!

Where you read the message:

Code: Select all

<?php
if(isset($_POST['readmessage'])) {
$bypass = 1;
$randid = $_POST['randid'];
$date = $_POST['date'];

$updatemessage = "UPDATE messages SET readm='0' WHERE pid='$users_username' AND date='$date' AND randid='$randid'";
$user_query = mysqli_query($db_conx, $updatemessage);

$messageinfo = "SELECT * FROM messages where pid='$users_username' AND date='$date' AND randid='$randid'";
$user_query1 = mysqli_query($db_conx, $messageinfo);

$messageinfo3=mysqli_fetch_array($user_query1);

$messageinfo3['message'] =  nl2br(preg_replace('#(\\]{1})(\\s?)\\n#Usi', ']', stripslashes($messageinfo3['message'])));

echo "<b><font color='lime'>Subject: " . $messageinfo3['subject'] . "<br><br></b>From: " . $messageinfo3['sender'] . "      " . $messageinfo3['date'] . "<br><br>";    
echo " " . $messageinfo3['message'] . "<br><br><br>";

echo "<center><form method='post' action='messages.php'><input type='submit' value='Reply'></center><input type='hidden' name='reply' value='1'></form>";

echo "<br>";
echo "<center><form method='post' action='messages.php'><input type='submit' value='Delete'></center>
       <input type='hidden' name='deletemessage' value='1'>
       <input type='hidden' name='randid' value='$messageinfo3[randid]'>
       <input type='hidden' name='date' value='$messageinfo3[date]'>
       </form>";
       echo "<center><form method='post' action='messages.php'><input type='submit' value='Back to Inbox'>
       <input type='hidden' name='messages' value='1'>
          </form>";
}
 
Where I have started the Reply Information:

Code: Select all

<?php

if(isset($_POST['reply'])) {
$bypass = 1;
if($bypass != 1)

{

$message =  protect($_POST["message"], ENT_QUOTES);
$subject = protect($_POST["subject"], ENT_QUOTES);
$sendto = protect($_POST["sendto"], ENT_QUOTES);
$randid = rand(999,9999999);

$sql = "INSERT INTO `messages` (`pid`,`sender`,`message`,`subject`,`randid`) VALUES ('".$sendto."','".$users_username."','".$message."','".$subject."','".$randid."')";
$user_query3 = mysqli_query($db_conx, $sql);

echo "Message Sent";

}

$messageinfo = "SELECT * FROM messages where pid='$users_username' ";
$user_query1 = mysqli_query($db_conx, $messageinfo);
$messageinfo3=mysqli_fetch_array($user_query1);

echo "<div style='width:600px'>";
echo "<br><form method ='post' action = 'messages.php'>";
echo "Send To:   " . $messageinfo3['sender'] . "<input type = 'hidden' name = 'sendto' size = '25'>";
echo "</div>";    

echo "<div>";
echo "Subject:     " . $messageinfo3['subject'] . "<input type = 'hidden' name = 'subject' size = '25' maxlength='25'><br><br>";
echo "</div>";

echo "<div style='vertical-align: top';>";    
echo "Content:    <textarea onfocus='limitTextarea(this,20)'  rows='15' cols='60' maxlength = '600' name = 'message'>";
echo "</textarea><br>";
echo "</div>";

echo "<input type = 'hidden' name = 'reply' value = '1'>";
echo "                <input type = 'submit' name = 'reply' id = 'reply' value = 'Send Message'>";
echo "</form>";
}

?>
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Re: Reply Messages

Post by Epiales »

Okay, I was able to get the name to change in the reply form to the appropriate name by using:

Code: Select all

echo "<center><form method='post' action='messages.php?replyto=$messageinfo3[sender]'><input type='submit' value='Reply'></center><input type='hidden' name='reply1' value='1'></form>";

And then when you press the reply button, it will show their name using:

Code: Select all

echo "Send To:   <input type = 'text' name = 'sendto' size = '25' value= " . $_GET['replyto'] . ">";
But can't seen to get the subject to move over correctly :( grrr
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Re: Reply Messages

Post by Epiales »

Okay, so I have everything working perfect except for it displaying the subject when you hit the reply button. :( It won't carry over :(

Other than that, it puts everything where it should be and lets you reply to the person. :mrgreen: YAY me :)

I tried to do the subject the same way as the reply to... Like so:

Code: Select all

echo "<center><form method='post' action='messages.php?replyto=$messageinfo3[sender]'><form method='post' action='messages.php?subcontent=$messageinfo3[subject]'><input type='submit' value='Reply'></center><input type='hidden' name='reply1' value='1'></form>";
But doesn't work. Says it's undefined :(
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Re: Reply Messages

Post by Epiales »

Okay, I was able to get it working somewhat by this:

echo "<center><form method='post' action='messages.php?replyto=$messageinfo3[sender]&subcontent=$messageinfo3[subject]'><input type='submit' value='Reply'></center><input type='hidden' name='reply1' value='1'></form>";

But if the subject has two words or more, it will only show the FIRST word. Like if it were Testing This Message, the subject would only show Testing....a way to fix that?

Thanks!
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Re: Reply Messages

Post by Epiales »

Okay, I used the urlencode to try and work it out:

Code: Select all

echo "Subject:     <input type = 'text' name = 'subject' size = '50' maxlength='50' value=Re:" . urlencode($_GET['subcontent']) . "><br><br>";
This was the result:

Code: Select all

 Re:My+Game+Updates


Now I just need to get rid of the + symbols and somehow make then just spaces.

Okay, for now I can use my new function to remove the + and either add an _ or just make it no spaces:

Code: Select all

<?php
function myUrlEncode( $sString )
{
    return urlencode(str_replace( ' ' , '_' , $sString ));
}
?>
So it's either : " MyGameUpdates" or would be like "My_Game_Updates" Just have to figure which one I want :D
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
MikuzA
Posts: 394
Joined: Thu Aug 08, 2013 8:57 am

Re: Reply Messages

Post by MikuzA »

how about moving the subject to a $_POST instead of the URL as a $_GET?

<input type=hidden name=subject value='subject'>

or

just pass an ID through and fill the data for the reply from database.
Why so serious?

Business Intelligence, Data Engineering, Data Mining
PHP, HTML, JavaScript, Bash/KornShell, Python, C#, PL/SQL
MySQL, DB2, Oracle, Snowflake
Pentaho, DataStage, Matillion, Unity3D, Blender
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Re: Reply Messages

Post by Epiales »

MikuzA wrote:how about moving the subject to a $_POST instead of the URL as a $_GET?

<input type=hidden name=subject value='subject'>

or

just pass an ID through and fill the data for the reply from database.
I tried to do the type=hidden and it made the subject disappear. I'll check into it again. Thx!
Nothing fancy, but a work in progress!

http://gameplaytoday.net
Post Reply

Return to “Beginner Help and Support”