Form for Sending a Private Message to Search and Match Users
- Register Group with Captcha
- View Group Profile
- Edit Group Profile
- MC (Microcommunity) Search and Match
- MC (Microcommunity) Search and Match — Security
- MC (Microcommunity) Search and Match — JavaScript
- MC (Microcommunity) Search and Match — Form
- MC (Microcommunity) Search and Match — PHP
- MC Questionnaire
- Microcommunity (MC) Registration Script — Enter Questionnaire Data in Database
- MC Search and Match Profile and Account Management
- Login to MC Search and Match Profile and Account Management
- Logout of MC Search and Match Profile and Account Management
- MC Questionnaire Login
- MC Questionnaire Info
- Delete Group Account
- Forgot User Name
- Forgot Password
- Form to Send Private Message
- Send Private Message
- Private Message Outbox
- Private Message Inbox
- Delete Private Message from Inbox
- Delete Private Message from Outbox
- Private Message Logout
- Private Message Session Monitoring
- MC (Microcommunity) Search and Match Session Monitoring
- Configure File for Database Connection
- Captcha Script for Registration and Login
This script is called send-message-form.php
First, we start up a session and check that the session id is set. If not, we send them to Login to MC Search and Match Profile and Account Management. Next, we get 2 session variables (username and groupname) into $U and $G PHP variables. Next we GET the 'gr' variable from a URL query string—IF there WAS such a string. If not, we make $gr an empty string. The only time this query string is used is when someone is in the Private Message Inbox and wants to respond to an inbox message, so they click on the message's groupname, which is a link to the page we are discussing: Form to Send Private Message. The message's groupname will get put in the query string as gr like this:
<a HREF='send-message-form.php?gr=".$gr."'>".$gr."</a>
Either way, we sanitize $gr with strip_tags(), preg_replace(), htmlentities(), and stripslashes(). This makes it safe to display onscreen.
In the JavaScript section, there is a textCounter() function whose purpose is to control the number of characters that go into the message in the textarea box. It even undoes any characters beyond the last allowable character (the 700th). It is run off the onKeyDown and onKeyUp events in the textarea box, which also activate a counter so the user sees how many characters are left. The function parameters are field, which is the textarea box, countfield, which is the counter, and maxlength, which is 700.
The form is standard stuff, and it contains a title with a PHP groupname variable in it:
Form for Sending a Private Message (from <?php echo $G; ?>)
The script below is called: send-message-form.php
<?php
include_once"check-id.php";
$U=$_SESSION['username'];
$G=$_SESSION['groupname'];
$gr=$_GET['gr'];
if(!isset($gr)){$gr="";}
$pattern3 = '/[^a-zA-Z0-9\\_]/i';
$gr=strip_tags($gr);
$gr=preg_replace($pattern3, $replacement, $gr);
$gr=htmlentities(stripslashes($gr), ENT_QUOTES);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<TITLE>Form for Sending a Private Message</TITLE>
<meta name="description" content="Form for Sending a Private Message">
<meta name="keywords" content="Form for Sending a Private Message,Form for Submitting a Private Message,Send Message Form,Submit Message Form,Private Messaging,Private Message,php,javascript, dhtml, DHTML">
<script language="javascript">
mactest=(navigator.userAgent.indexOf("Mac")!=-1) //My browser sniffers
Netscape=(navigator.appName.indexOf("Netscape") != -1)
msafari=(navigator.userAgent.indexOf("Safari")!= -1)
wsafari=0; if(!mactest&&msafari){wsafari=1;msafari=0}
is_opera = 0; if(window.opera){is_opera=1}
is_ie_mac = 0; is_ie=0;if(document.all){is_ie=1}
function fixwidth(){if(Netscape||is_opera){e=document.getElementById('box');e.style.width='476px';e=document.getElementById('menu');e.style.width='116px';}}
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit){field.value = field.value.substring(0, maxlimit);}
else{countfield.value = maxlimit - field.value.length;}}
</script>
<STYLE TYPE="text/css">
BODY {margin-left:0; margin-right:0; margin-top:0;text-align:left;background-color:#ccc}
p, li {font:13px Verdana; color:black;text-align:left}
h1 {font:bold 28px Verdana; color:black;text-align:center}
h2 {font:bold 24px Verdana;text-align:center}
h3 {font:bold 15px Verdana;}
#box {background-color:#eee;position:absolute;top:50px;left:250px;width:500px;padding:10px;
border:2px solid blue}
#menu {background-color:#eee;position:absolute;top:50px;left:0px;width:130px;padding:5px;
border:2px solid blue}
</STYLE>
</head>
<body onload="fixwidth()">
<h1>Form for Sending a Private Message (from <?php echo $G; ?>)</h1>
<div id='menu'>
<a HREF="send-message-form.php">Send Message</a><BR><BR>
<a HREF="message-inbox.php">Message Inbox</a><BR><BR>
<a HREF="message-outbox.php">Message Outbox</a><BR><BR>
<a HREF="message-delete-received.php">Delete Inbox<BR>Message</a><BR><BR>
<a HREF="message-delete-sent.php">Delete Outbox<BR>Message</a><BR><BR>
<a HREF="login-to-mc.php">Login</a><BR><BR>
<a HREF="message-logout.php">Logout</a><BR><BR>
<a HREF="register-for-mc.php">Account Management</a>
</div>
<div id='box'>
<form action="send-message.php" method="post" name="sendpm">
<table width='476'>
<tr>
<td width='120' align='right'>To Group Name</td>
<td width='356' align='left'>
<input type="text" name="touser" id="touser" size="35" maxlength="40" value="<?php echo $gr; ?>">
</td>
</tr>
<tr>
<td width='120' align='right'>Subject</td>
<td width='356' align='left'>
<input type="text" name="subject" id="subject" size="35" maxlength="150">
</td>
</tr>
<tr>
<td width='120' align='right'>Message</td>
<td width='356' align='left'>
<textarea name="message" cols="35" rows="20" id="message" onKeyDown="textCounter(this.form.message,this.form.remLen,700)" onKeyUp="textCounter(this.form.message,this.form.remLen,700)"></textarea>
<input readonly type='text' name='remLen' size='3' maxlength='3' value="700"><br></td>
</tr>
<tr>
<td colspan="2">
<center><input type="submit" value="Send PM"></center>
</td>
</tr>
</table>
</form>
</div>
</body>
</html>