Private Message Sending Form for Form Creator Form CMS
This script is called send-message-form_.php
The Private Message Sending Form for Form Creator Form CMS script is one of a group of PHP scripts that handle both the administrative and end-user aspects of a general purpose HTML Form Creator that allows not just input boxes but multiple selection enabled select/option lists as well. In addition to the expectable editing scripts for both administrative and end-user functions, there's also a Search and Match script so that users can use the scripts to find other users with various individual or group commonalities, including proximity searches, i.e., find all the users within various distances. There are even private messaging scripts.
In case you wonder why private messaging is related to a general purpose HTML Form Creator, the answer isn't really that odd. Although there are a zillion possible uses one can put custom, administrator-created forms to, and equally as many form configurations one can create, the two most prominent uses we envisioned when we created our HTML form creator are matching apps for individuals and matching apps for groups. An example of the former is dating site apps like Match.com and an example of the latter is MC (Microcommunity) Search and Match — Search for Compatible Groups. If you don't yet know what MCs are, feel free to go to The Big Answer and find out. It should be obvious that the first thing one does when looking for compatible people—either as individuals or groups—is contact the ones the matching apps find that you are compatible with. So our apps provide a link to a personal messaging script in both our matching script search results and in our Private Messaging Inbox, on this page. In the latter, when a user contacts you, you may use the provided link to reply.
In short, then, whether you want to make a form where clowns, boy scout troups, gays, stamp collectors, bird watchers, swingers, Elvis lovers, conspiracy theory advocates, or others find one another according to various compatibility standards you devise, or simply make a form unrelated to compatibility, matching, or searching, our form creator scripts will allow you to handle both the administrative and end-user aspects of a general purpose HTML Form Creator that allows not just input boxes but multiple selection enabled select/option lists as well. Let your imagination guide you in your usage of our CMS system for form creation and use.
- HTML Form Creator
- Edit Options in HTML Form Creator Form
- Administrator Page for HTML Form Creator
End-User HTML Form Creator Scripts
- HTML Form Creator—Register with Captcha
- HTML Form Creator—View Profile
- HTML Form Creator—Edit Profile
- HTML Form Creator—Search and Match
- HTML Form Creator—Search and Match — Security
- HTML Form Creator—Search and Match — JavaScript
- HTML Form Creator—Search and Match — Form
- HTML Form Creator—Search and Match — PHP
- HTML Form Creator—Enter Record in Form
- HTML Form Creator—View Record in Form
- HTML Form Creator—Profile and Account Management
- HTML Form Creator—Login to Profile and Account Management
- HTML Form Creator—Logout of Profile and Account Management
- HTML Form Creator—Delete Group Account
- HTML Form Creator—Forgot User Name
- HTML Form Creator—Forgot Password
- HTML Form Creator—Form to Send Private Message
- HTML Form Creator—Send Private Message
- HTML Form Creator—Private Message Outbox
- HTML Form Creator—Private Message Inbox
- HTML Form Creator—Delete Private Message from Inbox
- HTML Form Creator—Delete Private Message from Outbox
- HTML Form Creator—Private Message Logout
- HTML Form Creator—Search and Match Session Monitoring
- HTML Form Creator—Configure File for Database Connection
- HTML Form Creator—Captcha Script for Registration and Login
Administrative HTML Form Creator Scripts
The purpose of this script is to provide a form from which the user can send private messages. The form processor HTML Form Creator—Send Private Message takes care of filtering out unsafe or unacceptable content, then it enters the message into the my_privatemessages MySQL database table (creating the table in the db if it does not exist yet), then it emails the user that is getting the new personal message, letting him know about it. In using our HTML form creator CMS system, you may PM users anytime via the script on this page.
First, we start up a session (in the checkid_.php script) and then make sure the $_SESSION['sessionid'] is set, showing there must have been a login.
When we use the checkid_.php script to ensure that the session id variable is set, we send the user to register-with-captcha_.php if it is not. Then we put the session variable 'username' into $U and the session variable 'groupname' into $G. Now we GET the 'gr' variable which MAY have been sent from the HTML Form Creator—Search and Match script or the HTML Form Creator—Private Message Inbox as a URL query string as the user replies to a message he has received. (This variable will be put into the "touser" input box's value attribute via <input type="text" name="touser" id="touser" size="35" maxlength="40" value="<?php echo $gr; ?>">. You can see why we put an empty string into the value if no one sent a gr variable—to avoid forcing the user to see something as ugly as "undefined" in his "touser" input box.)
Or the user may simply get to this send message script using the Send Message link which can be found in all message related scripts in our HTML form creator CMS system. Or the user may use the Private Messages link in the HTML Form Creator—Profile and Account Management script—the CMS system's menu.
The strip_tags() function filters tags out of the recipient group the user MAY have input. Next come the regular expression replacement pattern, which allows only alphanumerics and underscores, and uses the PHP function preg_replace(). The PHP functions htmlentities() and stripslashes() are used on this group name, finally, to ensure safety in displaying it on the webpage as the value in the "touser" input box.
Next comes a JavaScript function textCounter(), which not only acts like the maxlength attribute—it's also a counter. The function textCounter() does what the HTML creators failed to do—find a way for programmers to insist on a limit to the size of the input in a textarea box. The maxlength attribute does not work in textarea tags, although it works fine in input tags for limiting text input size. The onKeyDown and onKeyUp events both call the textCounter() function from the textarea box used for message inputting. There's also a text counter so users know how many characters out of 700 they have left. The cool thing about the function is the way it INSISTS on the 700 character limit. When you try to type the 701st character, it's dumped so fast it wasn't really there—and there you are, still staring at only 700 characters. It does this with clever usage of the JavaScript substring() method. It deals with the counter by substracting the current length of the input string from 700 and sending it to a read-only input remLen.
The title for the message form says Form for Sending a Private Message, but it also gives who it's from, using PHP to echo $G to the screen. You may recall that $G is the $_SESSION['groupname'] which was defined in the HTML Form Creator—Login to Profile and Account Management script when this value was accessed in the MySQL table my_members. Note that the form action is send-message_.php—the HTML Form Creator—Send Private Message script.
The script below is called: send-message-form_.php
<?php
include_once"checkid_.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_.php">Login</a><BR><BR>
<a HREF="message-logout_.php">Logout</a><BR><BR>
<a HREF="profile-and-account-management.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>