Mail Form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ChrisInTn
Forum Newbie
Posts: 2
Joined: Wed Jan 17, 2007 7:00 pm

Mail Form

Post by ChrisInTn »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I've looked everywhere and tried everything and I'm stumped. Can somebody please help me by letting me know the proper format to send the contents of the form fields below via email? The form is working correctly, but I don't know how to send the contents of each form field I've defined. This is the part of the code below that begins with "mail". As it is now, it's sending on the contents of the "message" field, and I don't know how to add the others. I appreciate any help.

Code: Select all

<?

  $referers = array('www.website.com', 'website.com.com');
ini_set("SMTP","mail.website.com");

  $firstName = $_REQUEST['firstName'] ;
  $lastName = $_REQUEST['lastName'] ;
  $emailAddress = $_REQUEST['emailAddress'] ;
  $phoneNumber = $_REQUEST['phoneNumber'] ;
  $addressOne = $_REQUEST['addressOne'] ;
  $addressTwo = $_REQUEST['addressTwo'] ;
  $phoneNumber = $_REQUEST['phoneNumber'] ;
  $city = $_REQUEST['city'] ;
  $state = $_REQUEST['state'] ;
  $zipCode = $_REQUEST['zipCode'] ;
  $message = $_REQUEST['message'] ;

mail( "myemail@website.com", "Form Submitted on Website.com's Form",
   $message, "From: $emailAddress");

  header( "Location: http://www.website.com/confirm.php" );
  
?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

The third parameter of mail() is the message/mail body. You're passing $message as third parameter.
Currently only $_REQUEST['message'] is assigned to $message. You can append more values to $message, see http://www.php.net/manual/en/language.o ... string.php
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Post by dibyendrah »

If message should be sent in plain text, just append the text in using \n.

Code: Select all

$message = $firstName."\n".$lastName ."\n".$emailAddress."\n".$phoneNumber."\n".$addressOne."\n".$addressTwo."\n".$phoneNumber."\n".$city."\n".$state."\n".$zipCode."\n".$_REQUEST['message'] ; 
ChrisInTn
Forum Newbie
Posts: 2
Joined: Wed Jan 17, 2007 7:00 pm

Thank you

Post by ChrisInTn »

Thanks for the help; I appreciate it. I've solved the problem with your examples.
Post Reply