Jump to content

Stupid email form question


harville85

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!!!
Link to comment
https://forums.phpfreaks.com/topic/17290-stupid-email-form-question/
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>";

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!
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 = "[email protected]";

$mail->Password = "xxxxxx";


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

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


$mail->AddAddress("[email protected]");
$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");
?>
[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]

Archived

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

×
×
  • 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.