Location: PHPKode > projects > Modular Site Manager > htdocs/misc/pm.php
<?
chdir("../");
include "inc/functions.inc.php";
$mysql = new mysql(DB_MAIN);
if(!isset($_POST['subject']) || $_POST['subject'] == "")
{
	die("You must include a subject");
} elseif(!isset($_POST['message']) || $_POST['message'] == "")
{
	die("You must post a message.");
} elseif(!isset($_POST['user']) || $_POST['user'] == "")
{
	die("You must have a user to send to");
} else {
	$sel = $mysql->select(PRE."members", "username='".$_POST['user']."'", "id", "DESC", "1");
	if(mysql_num_rows($sel) < "1")
	{
		header("Location: ".$HTTP_REFERER."&pmerror=notuser");
	}
	while($a = mysql_fetch_assoc($sel))
	{
		$toid = $a['id'];
		mail($_POST['username']." <".$a['email'].">", "New private message", "You have a new private message on Vouksh.info from ".$_COOKIE['user'].".\n".SITE_URL."Members/Messages/Inbox", "FROM: Vouksh.info <hide@address.com>");
	}
	$mysql->query("INSERT INTO ".PRE."messages ( `toid` , `fromid` , `subject` , `message` , `owner` )
	VALUES ('".$toid."', '".$_COOKIE['mid']."', '".strip_tags($_POST['subject'])."', '".strip_tags($_POST['message'])."', '".$toid."')");
	$mysql->query("INSERT INTO ".PRE."messages ( `toid` , `fromid` , `subject` , `message` , `folder` , `owner` )
	VALUES ('".$toid."', '".$_COOKIE['mid']."', '".strip_tags($_POST['subject'])."', '".strip_tags($_POST['message'])."', 'sent', '".$_COOKIE['mid']."')");
	header("Location: ".SITE_URL."Members/Messages/Inbox");
}
?>
Return current item: Modular Site Manager