Jump to content

Archived

This topic is now archived and is closed to further replies.

harville85

Stupid email form question

Recommended Posts

I know this is probably so simple I'm going to cry after getting the answer, but I'll ask anyway: I can make a form on my website and it works great, sends the email over like it's supposed to, but how do I make it read like this:
Name: John Doe
Address: 123 st.
City: Doofus
State:XX
Instead of this:
John Doe
123 st.
Doofus
XX
I'm using PHP Mailer by the way. Any help would be appreciated!!!

Share this post


Link to post
Share on other sites
$body="
Name: $name\n
Address: $address\n
...
"

Share this post


Link to post
Share on other sites
Thanks, I'll see if I can make this work. While I do that, here's an example of what I have now that works, but it doesn't list the actual category in my email.

$text_body = $_POST['contact_name']. "<br>";
$text_body .= $_POST['city']. "<br>";
$text_body .= $_POST['state']. "<br>";
$text_body .= $_POST['zip_code']. "<br>";
$text_body .= $_POST['phone']. "<br>";
$text_body .= $_POST['fax']. "<br>";
$text_body .= $_POST['email']. "<br>";

Share this post


Link to post
Share on other sites

Name: $text_body = $_POST['contact_name']. "<br>";
City: $text_body .= $_POST['city']. "<br>";
$text_body .= $_POST['state']. "<br>";
$text_body .= $_POST['zip_code']. "<br>";
$text_body .= $_POST['phone']. "<br>";
$text_body .= $_POST['fax']. "<br>";
$text_body .= $_POST['email']. "<br>";

i think you can do that mate!

Share this post


Link to post
Share on other sites
I did what you suggested and I'm getting this when I click submit:

Parse error: parse error, unexpected ':' in C:\Sites\Single26\harville85\webroot\hd_mail.php on line 31

Share this post


Link to post
Share on other sites
Sure, here it is:

<?

require("c:\php\includes\class.phpmailer.php");


$mail = new PHPMailer();


$mail->IsSMTP();

$mail->Host = "mail.harvilledesign.com";

$mail->SMTPAuth = true;

$mail->Username = "info@harvilledesign.com";

$mail->Password = "xxxxxx";


$mail->From =
$_POST['email'];

$mail->FromName = "HD Web Contact Form";


$mail->AddAddress("info@harvilledesign.com");
$mail->IsHTML(true);

$mail->Subject = "HD Web Contact Form";

$text_body = $_POST['contact_name']. "<br>";
$text_body .= $_POST['city']. "<br>";
$text_body .= $_POST['state']. "<br>";
$text_body .= $_POST['zip_code']. "<br>";
$text_body .= $_POST['phone']. "<br>";
$text_body .= $_POST['fax']. "<br>";
$text_body .= $_POST['email']. "<br>";

$mail->Body = $text_body;



if(!$mail->Send())
{
echo "There was an error sending the message";
exit;
}

header("Location:thankyou_hd.html");
?>

Share this post


Link to post
Share on other sites
[quote author=harville85 link=topic=103925.msg414219#msg414219 date=1155336416]
Thanks, I'll see if I can make this work. While I do that, here's an example of what I have now that works, but it doesn't list the actual category in my email.

$text_body = $_POST['contact_name']. "<br>";
$text_body .= $_POST['city']. "<br>";
$text_body .= $_POST['state']. "<br>";
$text_body .= $_POST['zip_code']. "<br>";
$text_body .= $_POST['phone']. "<br>";
$text_body .= $_POST['fax']. "<br>";
$text_body .= $_POST['email']. "<br>";
[/quote]change in[code]
$text_body = "Name: ".$_POST['contact_name']. "<br>";
$text_body .= "City: ".$_POST['city']. "<br>";
etc.
[/code]

Share this post


Link to post
Share on other sites
easier still:

[code]<?php
$text_body = "Name: {$_POST['contact_name']}
City: {$_POST['city']}
etc.
Last field: {$_POST['last_field']}";

$message_content = nl2br($text_body);
?>[/code]

Share this post


Link to post
Share on other sites

×

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.