Código PHP:
<? include("include/functions.inc.php");
if(isset( $SID )){
session_start();
session_name($SID);
}
if(isset($_SESSION("USER_ID")))
{
$titulo = addslashes(trim(strip_tags($_POST["txt_titulo"])));
$tipo = addslashes(trim(strip_tags($_POST["txt_tipo"])));
$mensaje = addslashes(trim(strip_tags($_POST["txt_mensaje"])));
$error = "";
if(empty($titulo)) $error.="t";
if(empty($mensaje)) $error.="m";
if($error!=""){
header("Location: rmc.php?error=$error");
}else{
$link=conecta();
$user=mysql_query("select * from tbl_user where user_id=".$_SESSION["USER_ID"]) or die("error identificado 1");
$rs=mysql_fetch_array($user);
$fecha=date(d."/".m."/".Y);
$sql_msg="insert into tbl_msg_msg (msg_date,msg_from,msg_type,msg_subject,msg_msg, msg_email,msg_status) values ('".$fecha."','".$_SESSION[ss_username]."','".$tipo."','".$titulo."','".$mensaje."','".$rs["user_email"]."','N')";
mysq_query( $sql_msg ) or die("error identificado");
header("Location: rmc.php?send=ok");
}
}else{
$link=conecta();
$nombre = addslashes(trim(strip_tags( $_POST["txt_name"] )));
$email = addslashes(trim(strip_tags( $_POST["txt_email"] )));
$titulo = addslashes(trim(strip_tags( $_POST["txt_titulo"] )));
$tipo = addslashes(trim(strip_tags( $_POST["txt_tipo"] )));
$mensaje = addslashes(trim(strip_tags( $_POST["txt_mensaje"] )));
$error="";
if(empty($nombre)) {
$error.="n";
}
if(empty($email)){
$error.="e";
}
if(empty($titulo)){
$error.="t";
}
if(empty($mensaje))
{
$error.="m";
}
if($error!=""){
header("Location: rmc.php?error=$error");
}else{
$fecha=date(d."/".m."/".Y);
$sql_msg="insert into tbl_msg_msg (msg_date,msg_from,msg_type,msg_subject,msg_msg, msg_email,msg_status) VALUES ('".$fecha."','".$nombre."','".$tipo."','".$titulo."','".$mensaje."','".$email."','N')";
mysq_query( $sql_msg ) or die("error NO identificado");
header("Location: rmc.php?send=ok");
}
}
?>