I'm sure this is a real easy one for you but I'll be damned if I can find teh info I want anywhere!
I have created an 'internal messaging system' that allows our users to send each other messages throught the site, kind of like the private messaging service on this site, but I wanted to add an option to send by email too. I am using Form2mail to send the emails and I have modified a script that will pass the POSTed data to the Form2mail script. Problem is that I don't know how to pass it on.
Here is the page as I have it now (Note that it works fine until I chose the option to send email, I get nothing then, I don't know how to get it to send the form automatically:
Code: Select all
<?php
session_start();
header("Cache-control: private");
include ("../action/connect.php");
$send_to = $_POST["send_to"]; //-- username to send the mail to --//
$subject = $_POST["subject"]; //-- subject the mail is about --//
$from = $_POST["from"]; //-- username of the sender --//
$from_f = $_POST["from_f"]; //-- firstname of the sender --//
$from_l = $_POST["from_l"]; //-- lastname of the sender --//
$message = $_POST["message"]; //-- actual message to send --//
$important = $_POST["important"]; //-- if should be marked as important --//
$email = $_POST["email"]; //-- Will be "1" if should also send email --//
//-- Send the message to the internal inbox --//
mysql_query ("insert into message values('','$send_to','$from','$from_f','$from_l',now(),'1','$important','$subject','$message')");
//-- If email option is chosen, send an email as well --//
if ($email == "1") {
$recemail = mysql_query ("SELECT email FROM message WHERE username ='".$send_to."'");
$sendersemail = mysql_query ("SELECT email FROM message WHERE username ='".$from."'");
?>
<form action="../cgi-bin/form2mail.cgi" method="post">
<INPUT type="hidden" name="recipient" value="<?=$recemail;?>">
<INPUT type="hidden" name="subject" value="<?=$subject;?>">
<INPUT type="hidden" name="realname" value="<?=$from_f." ".$from_l;?>">
<INPUT type="hidden" name="email" value="<?=$sendersemail;?>">
<INPUT type="hidden" name="comments" value="<?=$message;?>">
<!-- THIS IS WHERE I DONT KNOW HOW TO AUTOMATICALLY SUBMIT THIS INFO -->
</form>
<?php
}else{
header('Location: '."index.php");
}
?>