Kirupa Flash Email PHP

Can someone please advise me; I would like to add another input field in the Kirupa Flash/PHP form at http://www.kirupa.com/developer/actionscript/flash_php_email.htm
What do I need to add in the PHP code and is there any limitation on the name of this field?

Mayweed.

You can add another field without too much trouble at all. You need to add it in the $headers section. Notice that variables from Flash (those prefixed with $_POST) are concatenated with words by using a period.

Let’s say you want another text field called “Phone Number”. Give it a variable name, eg. phone_txt, then choose where you want it to appear in the email:


$headers = "From: " . $_POST["name"];     //outputs "From: Chris"
$headers .= "<" . $_POST["email"] . ">
"; //outputs "<myemail@address.com.au>" followed by a new line
$header .= "Phone: ". $_POST["phone"]; //outputs "Phone: 4546 1132"
$headers .= "Reply-To: " . $_POST["email"]; //outputs "Reply-To: myemail@address.com.au

followed, of course, by the rest of the code as it appears in the tutorial. The values for name, email etc are all examples.

You could even invite the user to enter a subject in the flash form, so using a textfield called subject_txt, you’d put in the php file:


$subject = $_POST["subject_txt"];

Welcome to the forums.
C

Thanks for the reply Carixpig
I tried you suggestion but the new field is not showing; could it be because I use a web based mail account? I would be grateful if you would check this code for me and let me know if I am missing something.

Mayweed.

<?php
$sendTo = "mayweed@mayweed.com";
$subject = “Web site reply”;
$headers = “From: " . $_POST[“name”];
$headers .= “<” . $_POST[“email”] .”>
";
$headers .= "Phone: ". $_POST[“phone”];
$headers .= "Reply-To: " . $_POST[“email”];
$message = $_POST[“message”];
mail($sendTo, $subject, $message, $headers);
?>

Howdy… :slight_smile:

Try this…


<?php
	$sendTo = "mayweed@mayweed.com";
	$subject = "Web site reply";
	$headers = "From: " . $_POST["name"] . "<" . $_POST["email"] . ">
";
	$headers .= "Reply-To: " . $_POST["email"];
 
	$message = $_POST["message"] . "
";
	$message .= "Phone: ". $_POST["phone"];
 
	mail($sendTo, $subject, $message, $headers);
?>

CyanBlue,
I tried your code and it works perfectly.
Thank you for that, it has helped me a lot.

Most humble Mayweed.

what carix was doing is adding the phone number to the header, this is what the email client reads to figure out the email address and other parts of the message, this was never displayed although if you had been able to open the mail file itself, you actually could have seen it. Cyan’s method worked because he simply added the phone number to the end of the message sent in the body of the email :wink:

just to let you know

Thank you for taking time to explain that, I didn’t want to become a nuisance by asking too many questions.
The problem lies in my original post; I imagine Carixpig would have supplied the appropriate code if I hadn’t forgotten to mention that I am using a web based mail account.

much appreciated,

Mayweed.