Very basic Email content formatting PHP

This is a discussion on "Very basic Email content formatting PHP" within the PHP Forum section. This forum, and the thread "Very basic Email content formatting PHP are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jul 20th, 2007, 16:51
Junior Member
Join Date: Nov 2005
Location: Wisconsin
Age: 38
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Very basic Email content formatting PHP

I really know nothing at all about PHP language but I have this set up in an email php file that takes from a flash file. My question is how can I format this so that it doesn't just list the info. For instance, I would like it to display the information in the email like this:

Name: First, Last
Email: Email
Phone: Area-Phone
Message: Message

With each of these, the variable is shown after the ":"
PHP: Select all

<?
 
   $to 
"dblake@kiddykiosk.com";
$subject "Kiddy Kiosk Inquiry";
    
$msg "$First\n\n";
   
$msg .= "$Last\n\n";
   
$msg .= "$Area\n\n";
   
$msg .= "$Phone\n\n";
   
$msg .= "$Message\n\n";

  
mail($to$subject$msg"From: Kiddy Kiosk Contact \nReply-To: $Email\n");

?>
Thanks,
Dave

Last edited by karinne; Jul 23rd, 2007 at 15:00. Reason: Please use [php]...[/php] tags when displaying PHP code!
Reply With Quote

  #2 (permalink)  
Old Jul 20th, 2007, 19:08
c010depunkk's Avatar
SuperMember

SuperMember
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to c010depunkk
Re: Very basic Email content formatting PHP

1, 2, 3, here you go:

PHP: Select all

<?
$to
="dblake@kiddykiosk.com";
$subject="Kiddy Kiosk Inquiry";
$msg="Name: ".$First." ".$Last;
$msg.="\nEMail: ".$Email;
$msg.="\nPhone: ".$Area."-".$Phone;
$msg.="\nMessage: ".$Message;
mail($to$subject$msg"From: Kiddy Kiosk Contact \nReply-To: ".$Email."\n");
?>
You're welcome. Feel free to ask if you have any questions or if this doesn't work.
Reply With Quote
  #3 (permalink)  
Old Jul 20th, 2007, 19:37
Junior Member
Join Date: Nov 2005
Location: Wisconsin
Age: 38
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Very basic Email content formatting PHP

Well for some reason it doesn't send the email with the revised code. Just to make sure I gave you the correct info, here are my variable names from the input fields of the flash form:

First
Last
Email
Area
Phone
Message

Thanks again for your help,
Dave
Reply With Quote
  #4 (permalink)  
Old Jul 21st, 2007, 10:03
c010depunkk's Avatar
SuperMember

SuperMember
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to c010depunkk
Re: Very basic Email content formatting PHP

OK, I was assuming that the post values were already stored in the PHP variables?? Try this:
PHP: Select all

<?
$to
="dblake@kiddykiosk.com";
$subject="Kiddy Kiosk Inquiry";
$msg="Name: ".$_POST['First']." ".$_POST['Last'];
$msg.="\nEMail: ".$_POST['Email'];
$msg.="\nPhone: ".$_POST['Area']."-".$_POST['Phone'];
$msg.="\nMessage: ".$_POST['Message'];
mail($to$subject$msg"From: Kiddy Kiosk Contact \nReply-To: ".$_POST['Email']."\n");
?>
Reply With Quote
  #5 (permalink)  
Old Jul 23rd, 2007, 13:29
Junior Member
Join Date: Nov 2005
Location: Wisconsin
Age: 38
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Very basic Email content formatting PHP

That code works and displays the variable info in the email, but is still displays it like this:


David

Blake

715

443-3344

Test 2


This is how I would like it:

Name: David Blake
Phone Number: 715-9443-3344
Message:
Test 2

So it would display the word "Name" and then the variable from the form fields, the words "Phone Number" and then the values from the fields, etc..

Hope this makes sense.

Dave
Reply With Quote
  #6 (permalink)  
Old Jul 23rd, 2007, 14:38
c010depunkk's Avatar
SuperMember

SuperMember
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to c010depunkk
Re: Very basic Email content formatting PHP

huh? The code in both of my posts does exactly what you are describing??? Post the code you are using again.
Reply With Quote
  #7 (permalink)  
Old Jul 23rd, 2007, 14:58
Junior Member
Join Date: Nov 2005
Location: Wisconsin
Age: 38
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Very basic Email content formatting PHP

Here's all the code I have in the php page:
PHP: Select all

<?
$to
="dblake@kiddykiosk.com";
$subject="Kiddy*Kiosk*Inquiry";
$msg="Name:*".$_POST['First']."*".$_POST['Last'];
$msg.="\nEMail:*".$_POST['Email'];
$msg.="\nPhone:*".$_POST['Area']."-".$_POST['Phone'];
$msg.="\nMessage:*".$_POST['Message'];
mail($to,*$subject,*$msg,*"From:*Kiddy*Kiosk*Contact*\nReply-To:*".$_POST['Email']."\n");
?>

Last edited by karinne; Jul 23rd, 2007 at 15:00. Reason: Please use [php]...[/php] tags when displaying PHP code!
Reply With Quote
  #8 (permalink)  
Old Jul 23rd, 2007, 15:52
c010depunkk's Avatar
SuperMember

SuperMember
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to c010depunkk
Re: Very basic Email content formatting PHP

HMMM. Here's an example page that I tested and it does work:
PHP: Select all

<html>
<head>
<title>email test</title>
</head>
<body>
<?
$to
="dblake@kiddykiosk.com";
$subject="Kiddy Kiosk Inquiry";
$msg="Name: ".$_POST['First']." ".$_POST['Last'];
$msg.="\nEMail: ".$_POST['Email'];
$msg.="\nPhone Number: ".$_POST['Area']."-".$_POST['Phone'];
$msg.="\nMessage: ".$_POST['Message'];
echo(
$to."<br />".$subject."<br /><br />".$msg);
//mail($to,$subject,$msg,"From: Kiddy Kiosk Contact \nReply-To: ".$_POST['Email']."\n");
?>
<br /><br /><br />
<form name="test" method="post" action="mt.php">
<p>First Name: <input type="text" name="First" /></p>
<p>Last Name: <input type="text" name="Last" /></p>
<p>Email: <input type="text" name="Email" /></p>
<p>Area: <input type="text" name="Area" /></p>
<p>Phone: <input type="text" name="Phone" /></p>
<p>Message:</p>
<p><textarea name="Message" rows="5" cols="50"></textarea></p>
<p><input type="submit" action="submit" value="send" /></p>
</form>

</body>
</html>
It just outputs the posted values instead of sending them, but that will also work.
Reply With Quote
  #9 (permalink)  
Old Jul 23rd, 2007, 19:15
Junior Member
Join Date: Nov 2005
Location: Wisconsin
Age: 38
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Very basic Email content formatting PHP

Now it won't even send the email anymore. I think I'm retarded. I'm going to back off for a bit and come back at this with a fresh look and see if I can figure out what's going on.

Thanks for all your help though!

Dave
Reply With Quote
  #10 (permalink)  
Old Jul 23rd, 2007, 19:18
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Very basic Email content formatting PHP

The code posted above won't send the email

Quote:
Originally Posted by c010depunkk View Post
It just outputs the posted values instead of sending them, but that will also work.
I was just to show you that it should work
Reply With Quote
  #11 (permalink)  
Old Jul 24th, 2007, 05:02
Reputable Member
Join Date: Jul 2005
Location: Melksham, Wilts, UK
Posts: 293
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Very basic Email content formatting PHP

Quote:
Originally Posted by David Blake View Post
Now it won't even send the email anymore. I think I'm retarded. I'm going to back off for a bit and come back at this with a fresh look and see if I can figure out what's going on.
1. You need to remove the // in front of the mail statement for it to work; the // in the example turns that line into a comment.

2. Even then, it will only work if you call it mt.php as that's the name of the page that the form submits to.
Reply With Quote
  #12 (permalink)  
Old Jul 24th, 2007, 13:13
Junior Member
Join Date: Nov 2005
Location: Wisconsin
Age: 38
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Very basic Email content formatting PHP

Well I finally got it going! (at least it works now anyway!)
Here is the code I used...

<?php
$sendTo = "dblake@kiddykiosk.com";
$subject = "Kiddy Kiosk Inquiry";

$message="Name:*".$_POST['First']."*".$_POST['Last'];
$message.="\nEmail:*".$_POST['Email'];
$message.="\nPhone:*".$_POST['Area']."-".$_POST['Phone'];
$message.="\nCellphone:*".$_POST['CellArea']."-".$_POST['CellPhone'];
$message.="\nLocation:*".$_POST['City']."-".$_POST['State'];
$message.="\nMessage:*".$_POST['Message'];

mail($sendTo, $subject, $message, "From: Kiosk Contact Form\n");

?>

Thanks everyone for all your help!
Dave
Reply With Quote
  #13 (permalink)  
Old Jul 24th, 2007, 13:53
c010depunkk's Avatar
SuperMember

SuperMember
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to c010depunkk
Re: Very basic Email content formatting PHP

No problem, it's always a pleasure...

GO DAVE!!!
Reply With Quote
Reply

Tags
php language

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Expandable Content Script (Swtich Content) Matc JavaScript Forum 0 Apr 8th, 2008 10:53
Content Placement + Content Dividing josephman1988 Website Planning 2 Jan 22nd, 2008 05:02
Form submits to email via php, but email is blank!!?? DH1234 PHP Forum 2 Jun 18th, 2007 10:42
Newbie Question- Basic HTML email method="post" Bagel Web Page Design 4 Aug 18th, 2006 12:03
XML Help for Newbie - Formatting Content AceTutor Other Programming Languages 0 Jul 31st, 2006 12:04


All times are GMT. The time now is 01:56.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43