Hi folks,
Have this .php for a contact form.
Its working by sending an email about inquries, BUT I`m missing the info about several fields (Name, E-mail, Subject) in recieved emails.
<?php include_once('common/header.php');
require 'mail/PHPMailerAutoload.php';
?>
<script language="JavaScript" src="gen_validatorv31.js" type="text/javascript"></script>
<script language='JavaScript' type='text/javascript'>
function refreshCaptcha()
{
var img = document.images['captchaimg'];
img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.random()*1000;
}
</script>
<?php
if(isset($_POST['name'])){$error=0;
if(empty($_SESSION['6_letters_code'] ) ||
strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0)
{ $error=1;
}
$name=$_POST['name'];
$email=$_POST['email'];
$mailsubject=$_POST['subject'];
$detail=$_POST['detail'];
if($error==0){
/*$subject='Contect From Query';
$txt="Name :" .$name ."\r\n<br>";
$txt=$txt."Email :" .$email."\r\n<br>";
$txt=$txt."Subject :" .$mailsubject."\r\n<br>";
$txt=$txt."Message :" .$detail."\r\n<br>";
$to='mail@mysite.com';
$header = "From:".$name."<".$email.">\r\n";
$header .= "MIME-Version: 1.0 \r\n";
$header .= "Content-type: text/html; charset=iso-8859-1\r\n";
$sent=mail($to,$subject,$txt,$header);*/
$text = "Contact From Query";
//php mailer class
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'myserver.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'info@mysite.com'; // SMTP username
$mail->Password = 'averylongpassword'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
//$mail->Mailer = "smtp";
$mail->From = 'info@mysite.com';
$mail->FromName = 'mysite.com';
$mail->addAddress('mail@mysite.com'); // Add a recipient
//$mail->addAddress('ellen@example.com'); // Name is optional
$mail->addReplyTo('info@mysite.com', 'mysite.com');
//$mail->addCC('cc@example.com');
//$mail->addBCC('bcc@example.com');
// Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'From mysite.com';
$mail->Header = $name;
$mail->Body = $detail;
//$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send())
{
echo "<script>alert('mail not sent')</script>";
}
else
{
$wel_id = mt_rand ( 10 , 20 );
echo "<script>alert('Thank you for the request! Our response time is normally within one year')</script>";
}
}
}
?>
<div class="layout-2cols">
<div class="content grid_8">
<div class="single-page">
<div class="wrapper-box box-post-comment">
<h2 class="common-title">Contact Us</h2>
<div class="box-white">
<?php if(isset($error) && $error==1){ ?> <p id="captchaerror" style="color:#F00"> The captcha code does not match</p><?php unset($error);}?>
<?php if(isset($sent)){ ?> <p id="captchaerror" style="color:#090"> Mail sent successfully </p><?php unset($sent); }else{?>
<form action="" method="post">
<div class="contact-form">
<div class="input-group">
<input type="text" placeholder="Name/Company" required="required" name="name" value="<?php echo htmlentities($name) ?>"/>
</div>
<div class="input-group">
<input type="email" placeholder="E-mail" name="email" required="required" value="<?php echo htmlentities($email) ?>"/>
</div>
<div class="input-group">
<input type="text" placeholder="Subject" name="subject" required="required" value="<?php echo htmlentities($subject) ?>"/>
</div>
<div class="input-group">
<textarea type="text" placeholder="Description" name="detail" required="required"><?php echo htmlentities($detail) ?></textarea>
</div>
<div class="input-group">
<img src="captcha_code_file.php?rand=<?php echo rand(); ?>" id='captchaimg' >
<input type="text" placeholder="Capcha" name="6_letters_code" required="required"/>
</div>
<div class="input-group">
<button type="submit" value="submit">Submit</button>
</div>
</div>
</form>
<?php ;}?>
</div>
</div>
<!--end: .box-list-comment --> </div>
</div>
<?php include('common/rightside.php');?>
<!--end: .content -->
<!--end: .sidebar -->
<div class="clear"></div>
</div>
<?php include_once('common/footer.php');?>
I have no skills what so ever in php, and I would be happy if some of you could help me with this issue.
Thanks!