PDA

View Full Version : PHP form queries



g_force
09-15-2008, 09:14 AM
There are two forms that I have created (in actionscript 3.0) which refer to two php files.

1) This is for the user to refer friends to the site so they fill in:

-their email
-their friends name
-their friends email

I want to forward these details on to myself but with a different message (not simply BCC). How can I do that? (my current code is below)


<?php

// Create local PHP variables from the info the user gave in the Flash form -disabled message field
$toName = $_POST['toName'];
$toEmail = $_POST['toEmail'];
$fromEmail = $_POST['fromEmail'];

// Strip slashes on the Local variables -disabled message field
$toName = stripslashes($toName);
$toEmail = stripslashes($toEmail);
$fromEmail = stripslashes($fromEmail);

$to = $toEmail;
$from = $fromEmail;
$subject = "title";
//Begin HTML Email Message
$message = <<<EOF
<html>
<body bgcolor="#FFFFFF">
<b>Hi $toName,<br />
<b> check this out !! <br />
<b> <a href="http://website.com</a><br />
<b> <br />
</body>
</html>
EOF;
//end of message
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
$to = "$to";

mail($to, $subject, $message, $headers);

exit();
?>

2) The data for the second form is sent directly to me - here users enter:

-their name
-their email
-their comment

The current code below is modified from the first but does not show the variables in the message so I do not get any of those details. What must I do here? (code again is below)


<?php

// Create local PHP variables from the info the user gave in the Flash form -disabled message field
$fromname = $_POST['fromname'];
$fromemail = $_POST['fromemail'];
$fromcomments = $_POST['fromcomments'];

// Strip slashes on the Local variables -disabled message field
$fromname = stripslashes($fromname);
$fromemail = stripslashes($fromemail);
$fromcomments = stripslashes($fromcomments);

$from = $fromemail;
$subject = "my title";
//Begin HTML Email Message
$message = <<<EOF
<html>
<body bgcolor="#FFFFFF">
<b>New entry<br />
<b> print_r($_POST);
<br />
<b> <a href="http://www.mywebsite.com">www.mywebsite.com</a><br />
</body>
</html>
EOF;
//end of message
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
$to = "myemail@myhost.com";

mail($to, $subject, $message, $headers);

exit();
?>

Saluting all who can lend a hand with any of these.