Location: PHPKode > projects > PHP SQL tools > prfile/send_message.php
<?
include("identify.php");
load_all("send_message",1,1);

$stop = false;

if ( !(is_numeric($rec_id)) ) {
	$table_name = "users";
	$sql = "
		SELECT *
		FROM $table_name
		WHERE user_name = '$rec_id'
	";
	//echo "$sql<br>";
	$result = @mysql_query($sql, $main_settings->connection) or die("Couldn't execute query.");
	$row = mysql_fetch_array($result);
	$crap = $row['id'];
	if ($crap == "") {
		$stop = true;
		$msg = 1;
	} else {
		$rec_id = $crap;
	}
}

if ($rec_id == "") {
	$stop = true;
	$msg = 2;
}

$table_name = "messages";
$message_date = strtotime($main_settings->server_time);
if ($subject == "") {
	$subject = "[blank]";
}
if ($stop == false) {
	$sql = "
		INSERT INTO $table_name
		(id, sender_id, rec_id, subject, content, urgency, date)
		VALUES
		(\"\", \"$main_user->id\", \"$rec_id\", \"$subject\", \"$content\", \"$urgent\",\"$message_date\") 
	";

	$result = @mysql_query($sql, $main_settings->connection) or die("Couldn't execute query.");

	header ("Location: user.php?user_id=$main_user->id");
} else {

	topheader();
	echo "Problem Sending Message";
	botheader();

	topcontent();
	if ($msg == 1) {
		echo "The user name you specified [$rec_id] was not found.  Please try again<br>";
		echo "<a href=\"msg_sender.php\">Return</a>";
	} else if ($msg == 2) {
		echo "You need to enter a user name or id number.<br>";
		echo "<a href=\"msg_sender.php\">Return</a>";
	}
	
	botcontent();
	include("botpage.inc");
	die;	
}

?>
Return current item: PHP SQL tools