Hello,
I have been trying to make contact us works. It appears that it works like I receive a success message but in actual it doesn't work like it suppose to:
index.php
<form action="contact.php" name="contactform" class="row" method="post">
<h4>Request a FREE TRIAL CLASS!</h4>
<div id="input_name" class="col-md-12">
<input id="name" class="form-control" type="text" name="stu_fname" placeholder="Full Name">
</div>
<div id="input_email" class="col-md-12">
<input id="email" class="form-control" type="text" name="stu_email" placeholder="Enter your email">
</div>
<div id="input_phone" class="col-md-12">
<input id="phone" class="form-control" type="text" name="stu_telp" placeholder="Phone Number">
</div>
<p>We will respond to you within 24 hours, during regular business hours. All fields are required</p>
<!-- Submit Button -->
<div id="form_register_btn" class="text-center">
<input class="btn btn-theme" type="submit" name="request" value="Request Quotation" id="submit">
</div>
contact.php
<body>
<?php
include('includes/koneksi.php');
// PHP Mailer
require 'C:/xampp/htdocs/phpmailer/PHPMailerAutoload.php';
//memanggil library php mailernya
function smtpmailer($to, $from, $from_name, $subject, $body) {
global $error;
$mail = new PHPMailer();
//$mail->AuthType = 'NTLM';
$mail->IsSMTP();
//$mail->SMTPDebug = 0; // untuk memunculkan pesan error /debug di layar
$mail->SMTPAuth = true; // authentifikasi smtp enable atau disable
$mail->SMTPSecure = "";//‘ssl atau di kosongkas jika none’; // secure transfer membutuhkan authentifikasi dari mail server
$mail->Host ='ssl://smtp.gmail.com:465;tls://smtp.gmail.com:587'; // masukkan nama host email “diawal ssl://”
$mail->Port = 587; //port secure ssl email
$mail->Username = "squprime@gmail.com"; //username email
$mail->Password = "********"; //password email
$mail->SetFrom($from, $from_name);
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAddress($to);
if(!$mail->Send()) {
$error = "Mail error: ".$mail->ErrorInfo;
return false;
} else {
$error = "Message sent!";
return true;
}
}
$result = mysql_query("SELECT * FROM student ORDER BY student_id DESC") or die(mysql_error());
//$result = mysql_query("SELECT student_id FROM student ORDER BY student_id DESC") or die(mysql_error());
$data = mysql_fetch_array($result);
// write program to send email to the recorded email address
$name = $data['stu_fname'];
$email = $data['stu_email'];
$phone = $data['stu_telp'];
$message = "Dear ".$data['stu_fname'].","."\r\r".
"Please click the link below to continue the registration progress: ".
"http://www.squprime.com/registration3.php?student_id=".$data['student_id'];
/*if (@$_POST['submit']) {*/
if ($name&&$email&&$phone&&$message) {
if (is_numeric($phone)) {
$body = "
Name: ".$name."
Phone: ".$phone."
Email: ".$email."\n\n
".$message;
smtpmailer("squprime@gmail.com", "squprime@gmail.com", "Davy", "Test Email", $body);
//smtpmailer("squprime@indonusa.net.id", "squprime@indonusa.net.id", "Davy", "Test Email", $body); // script kirim email
echo "Your message has been sent, we will get back to your shortly.";
$name = trim("");
$email = trim("");
$phone = trim("");
$message = trim("");
}
else
echo "There should only be numbers in your phone number.";
}
else
echo "Please fill in <b>all</b> the fields!";
?>
<div id="contentForm">
<?php
header('Content-Type: text/html; charset=utf-8');
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
//$email_to = "cs@squprime.com";
$email_to = "squprime@gmail.com";
$email_subject = "SquPrime Free trial request!";
$first_name = $_POST['first_name']; // required
$email_from = $_POST['email']; // required
$phone = $_POST['phone']; // required
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Name: ".clean_string($first_name)."\n";
$email_message .= "Email Address: ".clean_string($email_from)."\n";
$email_message .= "Phone Number: ".clean_string($phone)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
//@mail($email_to, $email_subject, $email_message, $headers);
mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- Message sent! (change the text below as you wish)-->
<div class="container">
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
<div id="form_response" class="text-center">
<img class="img-responsive" src="img/thumbs/mail_sent.png" alt="image" />
<h1>Your request is sent!</h1>
<p>Thank you <b><?=$first_name;?></b>, our advisor will contact you within 24 hours!</p>
<a class="btn btn-theme btn-lg" href="index.php">Back To The Site</a>
</div>
</div>
</div>
</div>
<!--End Message Sent-->
<?php
}
?>
</div>
</body>
The message that is appears:
Your message has been sent, we will get back to your shortly.
When I check my email address I do not receive anything. I also check my student table database, no new row registration being added.