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



if ($storeprofileemail == 1)
{
    include ("inc/inc_getdate.php");
    $sent = $date." ".$ftime;
    $query = "INSERT INTO $emailtable ( strTo, strFrom, strSubject, strDate, memMessage) values( '$userid', '$gfcookie[1]', '$emailsubject', '$sent', '$emailmessage')";
    mysql_query( $query, $link ) or die ( "Error! : ".mysql_error() );
}

$result=mysql_query("SELECT * FROM $userstable WHERE strName = '$userid' LIMIT 0,1");
$num_rows = mysql_num_rows( $result );
while ( $a_row = mysql_fetch_object( $result ) )
{
    $address = $a_row->strEmail;
}

// uncomment the line below to allow email sending!

mail("$address", "$emailsubject", $emailmessage, "From: $emailfrom\r\n");

header("Location: profile.php?userid=$userid&groupid=$groupid&mailsent=1");
exit;