I have a personal message system set up on my site. The thing about it, is that when a person makes a new message, they are allowed to leave the subject blank. But, when the end user recieves the message, they have to click on the subject to read the message (The subject is used as the link to the messages' content).
What I need, is some way to have the script check if the subject has been left blank, and if so, to give a javascript pop-up message with the given error, all without refreshing the page (And thus, loosing the content of the message).
Here is the script:
PHP Code:
<?php
##################################################################
## Title........: myPMS II
## Description..: A Private Messaging System [PMS] for Mambo 4.5
## Author.......: Danial Taherzadeh
## Version......: 2.0 Beta
## Created......: 23/12/2003
## Contact......: [email="danialt@yahoo.com"]danialt@yahoo.com[/email]
## Mambo Version: 4.5 Stable
## Note: This script is a part of myPMS II package.
###################################################################
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
?>
<table width="100%" cellpadding="4" cellspacing="0" border="0" align="center" class="contentpane">
<tr>
<td colspan="2"><span class="contentheading"><?php echo _PMS_TITLE ?> : <?php echo _PMS_NEW ?></span></td>
</tr>
</TABLE>
<?php
echo _PMS_MENU;
if (isset($_POST['newsent']))
{
if ($_POST['recip'] == 'blank')
{
echo _PMS_NO_REC;
}
else
{
$time = date('H:i:s');
$date = date('Y-m-d');
$_POST[newmsg]=nl2br(addslashes($_POST[newmsg]));
$send = "INSERT INTO #__pms (id,groupname,username,whofrom,date,time,readstate,subject,message) VALUES ('','','$_POST[recip]','$my->username','$date','$time','','$_POST[newsub]','$_POST[newmsg]')";
$database->setQuery($send);
$result = $database->query();
mosRedirect('index.php?option=com_pms&page=inbox'._PMS_MSG_SENT);
}
}
$query="select username,name from #__users";
$database->setQuery($query);
$rows = $database->loadObjectList();
$users='<select class="inputbox" name="mylist" size=15 onChange="javascript:document.me.recip.value=document.me.mylist.value;"> ';
foreach ($rows as $row1) {
$users.="<option value=\"$row1->username\" ";
if ($row1->username=="$_GET[id]")
$users.= " SELECTED ";
$users.=">$row1->username ($row1->name)</option>";
}
$users.="</select>";
echo '<p>';
echo '<table cellspacing="0" cellpadding="5" border="0" class="contentpane" style="border=1px solid #D0D0D0" align=center>';
echo '<form method="post" action="index.php?page=new&option=com_pms" name="me">';
echo '<tr class=sectiontableentry1>
<td width=10%><b>'._PMS_TO.':</b></td>';
echo "<td>
<INPUT TYPE=\"TEXT\" name=\"recip\" size=\"30\" class=\"inputbox\">
</td>
<td rowspan=5 width=100% class=\"sectiontableentry2\" Valign='top'>
"._PMS_SELECT."
<br /><br />
$users</td>";
echo '</td></tr>';
echo '<tr><td><b>'._PMS_SUBJECT.':</b></td>';
echo '<td><input type="text" class="inputbox" name="newsub" size=40></td></tr>';
echo '<tr class=sectiontableentry1><td colspan=2><b>'._PMS_MESSAGE.':</b></td></tr>';
echo '<tr><td colspan=2><textarea name="newmsg" class="inputbox" rows=10 cols=50></textarea></td></tr>';
echo '<tr><td colspan=2><input type="submit" class=button name="newsent" value="'._PMS_SEND.'"></td></tr>';
echo '</table>';
echo '</form>';
echo '</p>';
?>
Bookmarks