Jump to content

help witch contact form [phpmailer]


slim charles

Recommended Posts

Hi,

sorry for this, i know it's kinda lame to ask for something in first post. But i'm desparate. I don't know much about php [well, i know almost nothing]. I needed a contact form for my site. So I found few examples online, for form with phpmailer and smtp. After few days, i managed to make it work. Except, all i got was empty email with text: "this is test" [as line $mail->Body = "" in .php file said]. My question is, what do i need to do to make it send whatever site visitors write in all of the fields?

 

<?php
require("class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP(); // send via SMTP
$mail->Host = "smtp.domain.com"; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "[email protected]"; // SMTP username
$mail->Password = "password"; // SMTP password

$mail->From = "[email protected]";
$mail->FromName = "Name";
$mail->AddAddress("[email protected]","Name");
$mail->AddReplyTo("[email protected]","Your Name");

$mail->WordWrap = 50; // set word wrap

$mail->IsHTML(true); // send as HTML

$mail->Subject = "Here is the subject";
$mail->Body = "This is the <b>HTML body</b>";
$mail->AltBody = "This is the text-only body";

if(!$mail->Send())
{
echo "Message was not sent <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}

echo "Message has been sent";

?> 

 

this is the code for the form:

<form action="contact.php" method="post" name="formular" id="formular">
        <input type="hidden" name="required" value="email,pismo" />
        <table width="227" border="0" align="center" cellpadding="0" cellspacing="0" id="table1268" style="border-collapse: collapse">
          
          <tr>

            <td width="227" style="font-family: Verdana, Arial, Helvetica, sans-serif"><table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" id="table1269" width="261">

                <tr>

                  <td width="261" style="font-family: Arial; font-size: 10pt; color: #999999; padding-left:4px; padding-right:2px"><div align="center" class="tabcrna">First and last name</div></td>

                </tr>

                <tr>

                  <td width="261" style="font-family: Arial; font-size: 10pt; color: #999999; padding-left:4px; padding-right:2px"><div align="center">

                      <input name="Ime" type="text" size="35" />

                  </div></td>

                </tr>

                <tr>

                  <td width="261" style="font-family: Arial; font-size: 10pt; color: #999999; padding-left:4px; padding-right:2px"><div align="center" class="tabcrna">Company </div></td>

                </tr>

                <tr>

                  <td width="261" style="font-family: Arial; font-size: 10pt; color: #999999; padding-left:4px; padding-right:2px"><div align="center">

                      <input name="Kompanija" type="text" size="35" />

                  </div></td>

                </tr>

                <tr>

                  <td width="261" style="font-family: Arial; font-size: 10pt; color: #999999; padding-left:4px; padding-right:2px"><div align="center" class="tabcrna">E-mail <span class="ver10"> <span lang="en-us" xml:lang="en-us">:</span></span></div></td>

                </tr>

                <tr>

                  <td width="261" style="font-family: Arial; font-size: 10pt; color: #999999; padding-left:4px; padding-right:2px"><div align="center">

                      <input name="Email" type="text" size="35" />

                  </div></td>

                </tr>

                <tr>

                  <td width="261" style="font-family: Arial; font-size: 10pt; color: #999999; padding-left:4px; padding-right:2px"><div align="center" class="tabcrna">Telephone:</div></td>

                </tr>

                <tr>

                  <td width="261" style="font-family: Arial; font-size: 10pt; color: #999999; padding-left:4px; padding-right:2px"><div align="center">

                      <input name="Telefon" type="text" size="35" />

                  </div></td>

                </tr>

                <tr>

                  <td width="261" style="font-family: Arial; font-size: 10pt; color: #999999; padding-left:4px; padding-right:2px"><div align="center" class="tabcrna">Fax:</div></td>

                </tr>

                <tr>

                  <td width="261" style="font-family: Arial; font-size: 10pt; color: #999999; padding-left:4px; padding-right:2px"><div align="center">

                      <input name="Fax" type="text" size="35" maxlength="15" />

                  </div></td>

                </tr>

                <tr>

                  <td width="261" style="font-family: Arial; font-size: 10pt; color: #999999; padding-left:4px; padding-right:2px"><div align="center" class="tabcrna">Subject:</div></td>

                </tr>

                <tr>

                  <td width="261" style="font-family: Arial; font-size: 10pt; color: #999999; padding-left:4px; padding-right:2px"><div align="center">

                      <textarea rows="5" name="Predmet" cols="25"></textarea>

                  </div></td>

                </tr>

                <tr>

                  <td width="261" style="font-family: Arial; font-size: 10pt; color: #999999; padding-left:4px; padding-right:2px"><div align="center" class="tabcrna">Comment:</div></td>

                </tr>

                <tr>

                  <td width="261" style="font-family: Arial; font-size: 10pt; color: #999999; padding-left:4px; padding-right:2px"><div align="center">

                      <textarea rows="5" name="Pismo" cols="25" id="Pismo"></textarea>

                  </div></td>

                </tr>

              </table>

                <p align="center" class="style7">

                  <input type="submit" value="Send" name="B1" style="font-family: Verdana; font-size: 10pt; font-weight: bold;" />

                  <input type="reset" value="Reset" name="B2" style="font-family: Verdana; font-size: 10pt; font-weight: bold" />

                </p></td>

          </tr>

        </table>

      </form>

 

so, once again, i'm sorry, but is there any way someone could help me with this? i'm going crazy....

Link to comment
https://forums.phpfreaks.com/topic/160462-help-witch-contact-form-phpmailer/
Share on other sites

Hi,

 

Add this code in the contact.php file after the line $mail->Subject = "Here is the subject";

 

$message     =    "<table cellpadding='2' cellspacing='2' border='0' width='100%'>";
$message    .=  "<tr><td colspan='2'>**************************************************************</td></tr>";
$message    .=    "<tr><td align='right'>Trade Enquiry</td><td> </td></tr>";
$message    .=  "<tr><td colspan='2'>**************************************************************</td></tr>";
$message    .=    "<tr><td align='left'>Ime:</td><td>".$_POST['Ime']."</td></tr>";
$message    .=    "<tr><td align='left'>Kompanija:</td><td>".$_POST['Kompanija']."</td></tr>";    
$message    .=    "<tr><td align='left'>Email:</td><td>".$_POST['Email']."</td></tr>";
$message    .=    "<tr><td align='left'>Telefon ID:</td><td>".$_POST['Telefon']."</td></tr>";
$message    .=    "<tr><td align='left'>Fax:</td><td>".$_POST['Fax']."</td></tr>";
$message    .=    "<tr><td align='left'>Predmet:</td><td>".$_POST['Predmet']."</td></tr>";
$message    .=    "<tr><td align='left'>Pismo:</td><td>".$_POST['Pismo']."</td></tr>";
$message    .=    "</table>";

$mail->Body = $message;

 

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.