Jump to content

message system


Glenskie

Recommended Posts

Here are some script that i have been working on and i seems to not work :( so i want to make a select friend list that when they select the friend that they want to send the message to it sends it to them , that sounded stupid but ya. so here is my script , kinda big .

pm_inbox.php i did edit the code from its original state because its to big! so here is the sections where is most needed

<?php

// Start_session, check if user is logged in or not, and connect to the database all in one included file
include_once("scripts/checkuserlog.php");
?>
<?php
if (!isset($_SESSION['idx'])) {
echo  '<br /><br /><font color="#FF0000">Your session has timed out</font>
<p><a href="login.php">Please Click Here</a></p>';
exit(); 
}
//THIS IS WHERE I STARTED
$selecteduser = $_POST["selecteduser"];
$id = "";
$username = "";
$id = preg_replace('#[^0-9]#i', '', $id);
$sql = mysql_query("SELECT * FROM myMembers WHERE id='$id' LIMIT 1");
while($row = mysql_fetch_array($sql)){ 
    $username = $row["username"];
$friend_array = $row["friend_array"];
$check_pic = "members/$id/image01.jpg";
$default_pic = "members/0/image01.jpg";
if (file_exists($check_pic)) {
    $user_pic = "<img src=\"$check_pic?$cacheBuster\" width=\"218px\" />"; 
} else {
$user_pic = "<img src=\"$default_pic\" width=\"218px\" />"; 
}

$selecteduser .= "<option value='$friend_array'>Friends</option>";



}






// Decode the Session IDX variable and extract the user's ID from it
$decryptedID = base64_decode($_SESSION['idx']);
$id_array = explode("p3h9xfn8sq03hs2234", $decryptedID);
$my_id = $id_array[1];
$my_uname = $_SESSION['username']; // Put user's first name into a local variable
// ------- ESTABLISH THE INTERACTION TOKEN ---------
$thisRandNum = rand(9999999999999,999999999999999999);
$_SESSION['wipit'] = base64_encode($thisRandNum); // Will always overwrite itself each time this script runs
// ------- END ESTABLISH THE INTERACTION TOKEN ---------
?>
<?php
// Mailbox Parsing for deleting inbox messages
if (isset($_POST['deleteBtn'])) {
    foreach ($_POST as $key => $value) {
        $value = urlencode(stripslashes($value));
	if ($key != "deleteBtn") {
	   $sql = mysql_query("UPDATE private_messages SET recipientDelete='1', opened='1' WHERE id='$value' AND to_id='$my_id' LIMIT 1");
	   // Check to see if sender also removed from sent box, then it is safe to remove completely from system
	}
    }
header("location: pm_inbox.php");
}
?>

// Start Private Messaging stuff
$('#pmForm').submit(function(){$('input[type=submit]', this).attr('disabled', 'disabled');});
function sendPM ( ) {
      var pmSubject = $("#pmSubject");
  var pmTextArea = $("#pmTextArea");
  var sendername = $("#pm_sender_name");
  var senderid = $("#pm_sender_id");
  var recName = $("#pm_rec_name");
  var recID = $("#pm_rec_id");
  var pm_wipit = $("#pmWipit");
  var url = "scripts_for_profile/private_msg_parse.php";
      if (pmSubject.val() == "") {
           $("#interactionResults").html('<img src="images/round_error.png" alt="Error" width="31" height="30" />   Please type a subject.').show().fadeOut(6000);
      } else if (pmTextArea.val() == "") {
	   $("#interactionResults").html('<img src="images/round_error.png" alt="Error" width="31" height="30" />   Please type in your message.').show().fadeOut(6000);
      } else {
	   $("#pmFormProcessGif").show();
	   $.post(url,{ subject: pmSubject.val(), message: pmTextArea.val(), senderName: sendername.val(), senderID: senderid.val(), rcpntName: recName.val(), rcpntID: recID.val(), thisWipit: pm_wipit.val() } ,           function(data) {
		   $('#private_message').slideUp("medium");
		   $("#interactionResults").html(data).show().fadeOut(10000);
		   document.pmForm.pmTextArea.value='';
		   document.pmForm.pmSubject.value='';
		   $("#pmFormProcessGif").hide();
           });
  }
}function toggleViewAllFriends(x) {
	if ($('#'+x).is(":hidden")) {
		$('#'+x).fadeIn(200);
	} else {
		$('#'+x).fadeOut(200);
	}
}
// End Private Messaging stuff</script>
<style type="text/css"> 
.hiddenDiv{display:none}
#pmFormProcessGif{display:none}
.msgDefault {font-weight:bold;}
.msgRead {font-weight:100;color:#666;}
</style>
</head>
<body>
<div id="bg" class="stage"></div> 
<div id="container">
<div id="sun" class="stage"></div>
<div id="clouds" class="stage">
	<div id="stage" class="stage">
<?php include_once "header_template.php"; ?>

        <a href="#" onclick="return false" onmousedown="javascript:toggleInteractContainers('private_message');">Compose Message</a></div><div class="interactContainers" id="private_message">

<form action="javascript:sendPM();" name="pmForm" id="pmForm" method="post" type="hidden">
<font size="+1">Send A Private Message to <strong><em><?php echo "$selecteduser"; ?></em></strong></font><br /><br />
Subject:
<input name="pmSubject" id="pmSubject" type="text" maxlength="64" style="width:98%;" />
Message:
<textarea name="pmTextArea" id="pmTextArea" rows="8" style="width:98%;"></textarea>
  <input name="pm_sender_id" id="pm_sender_id" type="hidden" value="<?php echo $_SESSION['id']; ?>" />
  <input name="pm_sender_name" id="pm_sender_name" type="hidden" value="<?php echo $_SESSION['username']; ?>" />
  <input name="pm_rec_id" id="pm_rec_id" type="hidden" value="<?php echo $id; ?>" />
  <input name="pm_rec_name" id="pm_rec_name" type="hidden" value="<?php echo $username; ?>" />
  <input name="pmWipit" id="pmWipit" type="hidden" value="<?php echo $thisRandNum; ?>" />
  <span id="PMStatus" style="color:#F00;"></span>
  <br /><input name="pmSubmit" type="submit" value="Submit" /> or <a href="#" onclick="return false" onmousedown="javascript:toggleInteractContainers('private_message');">Close</a>
<span id="pmFormProcessGif" style="display:none;"><img src="images/loading.gif" width="28" height="10" alt="Loading" /></span></form>
      </div>
              <span id="jsbox" style="display:none"></span>
            </td>
          </tr>
      </table>
       

Link to comment
Share on other sites

Since you gave us no specifi error or explanation, I'm just guessing: This block of code:

 

// Start Private Messaging stuff
$('#pmForm').submit(function(){$('input[type=submit]', this).attr('disabled', 'disabled');});
function sendPM ( ) {
      var pmSubject = $("#pmSubject");
  var pmTextArea = $("#pmTextArea");
  var sendername = $("#pm_sender_name");
  var senderid = $("#pm_sender_id");
  var recName = $("#pm_rec_name");
  var recID = $("#pm_rec_id");
  var pm_wipit = $("#pmWipit");
  var url = "scripts_for_profile/private_msg_parse.php";
      if (pmSubject.val() == "") {
           $("#interactionResults").html('<img src="images/round_error.png" alt="Error" width="31" height="30" />   Please type a subject.').show().fadeOut(6000);
      } else if (pmTextArea.val() == "") {
	   $("#interactionResults").html('<img src="images/round_error.png" alt="Error" width="31" height="30" />   Please type in your message.').show().fadeOut(6000);
      } else {
	   $("#pmFormProcessGif").show();
	   $.post(url,{ subject: pmSubject.val(), message: pmTextArea.val(), senderName: sendername.val(), senderID: senderid.val(), rcpntName: recName.val(), rcpntID: recID.val(), thisWipit: pm_wipit.val() } ,           function(data) {
		   $('#private_message').slideUp("medium");
		   $("#interactionResults").html(data).show().fadeOut(10000);
		   document.pmForm.pmTextArea.value='';
		   document.pmForm.pmSubject.value='';
		   $("#pmFormProcessGif").hide();
           });
  }
}function toggleViewAllFriends(x) {
	if ($('#'+x).is(":hidden")) {
		$('#'+x).fadeIn(200);
	} else {
		$('#'+x).fadeOut(200);
	}
}
// End Private Messaging stuff</script>

 

ends with a script closing tag (</script>) but there's no script start tag.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.