问题
I purchased a template from Template Monster and I can't figure out how to make the form work.
Here's the form code:
<form id="form">
<div class="success_wrapper">
<div class="success-message">Το μήνυμά σας εστάλη.</div>
</div>
<label class="name">
<input type="text" placeholder="Όνομα*:" data-constraints="@Required @JustLetters" />
<span class="empty-message">*Το πεδίο είναι υποχρεωτικό.</span>
<span class="error-message">*Το όνομα δεν είναι έγκυρο.</span>
</label>
<label class="email">
<input type="text" placeholder="Email*:" data-constraints="@Required @Email" />
<span class="empty-message">*Το πεδίο είναι υποχρεωτικό.</span>
<span class="error-message">*Το email δεν είναι έγκυρο.</span>
</label>
<label class="phone">
<input type="text" placeholder="Τηλέφωνο:" data-constraints=" @JustNumbers"/>
<span class="empty-message">*Το πεδίο είναι υποχρεωτικό.</span>
<span class="error-message">*Το τηλέφωνο δεν είναι έγκυρο.</span>
</label>
<label class="message">
<textarea placeholder="Μήνυμα:" data-constraints=' @Length(min=20,max=999999)'></textarea>
<span class="empty-message">*Το πεδίο είναι υποχρεωτικό.</span>
<span class="error-message">*Το μήνυμα είναι πολύ μικρό.</span>
</label>
<div>
<div class="clear"></div>
<div class="btns">
<a href="#" data-type="reset" class="">Καθαρισμος</a>
<a href="#" data-type="submit" class="">Αποστολη</a></div>
</div>
</form>
There is also a MailHandler.php in a folder named "bat" with the following code:
<?php
//SMTP server settings
$host = "smtp.host.com";
$port = "587";
$username = "";
$password = "";
$messageBody = "";
if($_POST['name']!='false'){
$messageBody .= '<p>Visitor: ' . $_POST["name"] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}
if($_POST['email']!='false'){
$messageBody .= '<p>Email Address: ' . $_POST['email'] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}else{
$headers = '';
}
if($_POST['state']!='false'){
$messageBody .= '<p>State: ' . $_POST['state'] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}
if($_POST['phone']!='false'){
$messageBody .= '<p>Phone Number: ' . $_POST['phone'] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}
if($_POST['fax']!='false'){
$messageBody .= '<p>Fax Number: ' . $_POST['fax'] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}
if($_POST['message']!='false'){
$messageBody .= '<p>Message: ' . $_POST['message'] . '</p>' . "\n";
}
if($_POST["stripHTML"] == 'true'){
$messageBody = strip_tags($messageBody);
}
if($host=="" or $username=="" or $password==""){
$owner_email = $_POST["owner_email"];
$headers = 'From:' . $_POST["email"] . "\r\n" . 'Content-Type: text/plain; charset=UTF-8' . "\r\n";
$subject = 'A message from your site visitor ' . $_POST["name"];
try{
if(!mail($owner_email, $subject, $messageBody, $headers)){
throw new Exception('mail failed');
}else{
echo 'mail sent';
}
}catch(Exception $e){
echo $e->getMessage() ."\n";
}
}else{
require_once 'Mail.php';
$to = $_POST["owner_email"];
$subject = 'A message from your site visitor ' . $_POST["name"];
$headers = array (
'From' => 'From:' . $_POST["email"] . "\r\n" . 'Content-Type: text/plain; charset=UTF-8' . "\r\n",
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory(
'smtp',
array (
'host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $messageBody);
try{
if(PEAR::isError($mail)){
echo $mail->getMessage();
}else{
echo 'mail sent';
}
}catch(Exception $mail){
echo $mail->getMessage() ."\n";
}
}
?>
Any help will be truly appreciated!
回答1:
Ok I figured this one out... You have to get into the forms javascript file it will look like TMForms.js or something like that in the file named JS, under the very top portion of the code that looks like this
okClass:'ok'
,emptyClass:'empty'
,invalidClass:'invalid'
,successClass:'success'
,onceVerifiedClass:'once-verified'
,mailHandlerURL:'http://www.yourwebsitename.com/bat/MailHandler.php
,successShowDelay:'4000'
,stripHTML:true
MAKE SURE TO PUT THE FULL URL PATH TO THE BAT FOLDER LIKE I HAVE in bold, this will fix your issue.
Replace yourwebsite name with your actual URL and you are good to go...
回答2:
You must contact the support from where your purchased the template, they can help you
来源:https://stackoverflow.com/questions/22759851/how-to-setup-a-contact-form-from-a-templatemonster-template-i-purchased