Jump to content

[SOLVED] Advanced Email form in php need help!


TRemmie

Recommended Posts

So I am building a flash -> php email form, and other then the basic name,email,subject,message boxes, I want to do boxes like with address, age, telephone number, etc. I would like the normal stuff obviously, but I would like to display all the detailed information about the person to appear in the message part of the email.

 

I can get the simple

<?php
//define the receiver of the email
$to = 'admin@website.com';
//define the subject of the email
$subject = $_REQUEST["Subject"];
//define the message to be sent. Each line should be separated with \n
$message = " - need help here - ";
//define the headers we want passed. Note that they are separated with \r\n
//send the email
$mail_sent = @mail( $to, $subject, $message );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" 
echo $mail_sent ? "Mail sent" : "Mail failed";
?>

 

Is there a way to call variables from multiple forms on the flash to the $message?

 

Link to comment
Share on other sites

If I understand your challenge correctly...

 

You can include as many form fields in the $message.

<?php
$message = "Thank you bla bla email content ";
$message .= "Name: ".$name; //the $name is from the form field that the user submitted $name = $_POST['name'];
$message .= "Telephone: ".$phone; //ditto
/* etc... just attach all the variables to the message. You will need the <br> /t /n for formatting the email depending on how you want to space the content inside. */
?>

 

 

Link to comment
Share on other sites

Got it! thanks  ;D

 

Final code running something along these lines:

 

<?php

$to = "name@domain.com";
$headers = "$_POST["email"] "
$subject = "subject of the email goes here" 
$msg = "$name\n\n";
$msg .= "$address\n\n";
$msg .= "$phonenumber\n\n";
$msg .= "$message\n\n";
mail($to, $subject, $msg, "From: $email\nReply-To: $email\n");

?>

   

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.