Flash form to PHP file help

Ive made a flash contact form that interacts with a “form.php” file after you hit “send” on the contact form.

Heres the code:

<html>
<head>
<title>Contact Form</title>
</head>

<body>
<?
$msg .= "Name: ".$_POST["name"]."
";
$msg .= "Email: ".$_POST["email"]."
";
$msg .= "Message: ".$_POST["message"]."
";

$to = "domo@hotmail.com";
$subject = "Email from domo's site".$_POST["subject"];

$mailheaders .= "Reply-To: ".$_POST["email"]."

";

$result = mail($to, $subject, $msg, $mailheaders);
?> 
</body>
</html>

When someone uses this form and I receive their email in my outlook express… it always says From: Nobody.

Does anyone know how to change my code so that it is changed from “nobody” to the persons mail who sent it?

Also, I was wondering how to edit my code to make sure that the email I get includes the senders IP address, just in case C:-)

Thanks,

Domo

try this

<?php
mail($to, $subject, $msg,"From: $_POST['name'] <$_POST['email']>
"."Reply-To: ".$_POST["email"]."

");
?>

and $_SERVER[‘REMOTE_ADDR’] resolves the user’s IP :slight_smile:

thanks :stuck_out_tongue: ill try it out

do i add that into my original code or just have that alone?

<?
$msg .= "Name: ".$_POST["name"]."
";
$msg .= "Email: ".$_POST["email"]."
";
$msg .= "Message: ".$_POST["message"]."
";

$to = "domo@hotmail.com";
$subject = "Email from domo's site".$_POST["subject"];

$mailheaders .= "From: $_POST['name'] <$_POST['email']>
"."Reply-To: ".$_POST["email"]."

";

$result = mail($to, $subject, $msg, $mailheaders);
?>

^Thanks for that!

Ill try it out and let you know how it goes

hmm…

This is the error I get:

Parse error: parse error, expecting T_STRING' orT_VARIABLE’ or `T_NUM_STRING’ in /home/domo/public_html/mx/form.php on line 15

Heres my code:

<?
$msg .= "Name: ".$_POST["name"]."
";
$msg .= "Email: ".$_POST["email"]."
";
$msg .= "Message: ".$_POST["message"]."
";

$to = "domo@hotmail.com";
$subject = "Email from domo's site".$_POST["subject"];

$mailheaders .= "From: $_POST['name'] <$_POST['email']>
"."Reply-To: ".$_POST["email"]."

";

$result = mail($to, $subject, $msg, $mailheaders);

$_SERVER['REMOTE_ADDR']
?> 

Think you can help me out?

Thanks :slight_smile:

i don’t see the purpose of the last line… remove it and it should be fine

I get the same error when it is removed.

I rewrote your script… it’s much cleaner now:

<?php

// define variables
$name = $_POST['name'];
$email = $_POST['email'];
$usr_subject = $_POST['subject'];
$message = $_POST['message'];
$IP = $_SERVER['REMOTE_ADDR'];

$to = "domo@hotmail.com";

// set $subject
$subject = "Email from domo's site $usr_subject";

// set $msg
$msg = "Name: $name 
Email: $email 
IP: $IP
Message: $message";

// define mail headers
$mailheaders = "From: $name <$email>";

$result = mail($to, $subject, $msg, $mailheaders);

?>

the script above i know works, just tested it… if it doesnt work for you, you’re on your own :wink:

and… why do you set the “reply-to” to be the reciever’s email??

i dont know - rofl im kind of a noob to PHP but I intend to learn it all 100% :P.

Thanks for your help, its greatly appreciated.

btw… the script works :smiley: