1
The problem is that I have a contact form, working all right, but I need it to contain more fields in the body of the email message.
For example, I have some fields like company, phone, etc... I would need that, in the body of the email, have them too.
Let’s go to the current situation of CODE PHP
<?php
$name = @trim(stripslashes($_POST['name']));
$from = trim($_POST["email"]);
$subject = "Contato via Site";
$message = trim($_POST["message"]);
$to = "[email protected]";
$headers = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/plain; charset=iso-8859-1";
$headers[] = "From: {$name} <{$from}>";
$headers[] = "Reply-To: <{$from}>";
$headers[] = "Subject: {$subject}";
$headers[] = "X-Mailer: PHP/".phpversion();
$header = implode("\r\n", $headers);
if (mail($to, $subject, $message, $header)) {
?>
<script language="JavaScript">
alert("Mensagem enviada.");
</script>
<script language='javascript'>history.back()</script>;
<?
}
?>
Unfortunately, my knowledge in PHP is virtually null.
In short:
I have a contact form, in it is sent only one field in the body of the email, the message. I need to add 3 more fields in the body, Name, Company and Phone.
Create a formatted string and assign it to
$message
. If you want then you can build a more incremented template.– rray