<?php
include ("inc/inc_connect.php");
include ("inc/inc_getdate.php");


if ($too == "randomvariablehere")
{
    $sendto = $to;
}
else
{
    $sendto = $too;
}

if ($too == "")
{
    $sendto = $to;
}


$query = "INSERT INTO $pmtable
                ( strTo, strFrom, strSubject, memMessage, strDateRecieved, strTimeRecieved, strEpochTime )
                values( '$sendto',
                        '$gfcookie[1]',
                        '$subject',
                        '$message',
                        '$date',
                        '$time',
                        '$epoch')";

                mysql_query( $query, $link )
                or die ( "Could not add data to \"$pmtable\" table: "
        .mysql_error() );

// fill in reply times if this is a reply.

if ($id > 0)
{
    $query = mysql_query( "UPDATE $pmtable SET strDateReplied = '$date', strTimeReplied = '$time', intReplied = '1' WHERE intId = '$id'");

    mysql_query( $query, $link );
}

// Jump back to the inbox page with the sent id set to 1.



header("Location: inbox.php?sent=1&name=$sendto");
exit;