如何从我购买的templatemonster模板设置联系表单? [英] How to setup a contact form from a templatemonster template I purchased?

查看:183
本文介绍了如何从我购买的templatemonster模板设置联系表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从Template Monster购买了一个模板,但我无法弄清楚如何使表单工作。

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>   

在名为bat的文件夹中还有一个 MailHandler.php 使用以下代码:

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!

推荐答案

好吧,我想出了这一个......你必须进入窗体JavaScript文件它看起来像TMForms.js或类似的文件名为JS,在顶部部分代码看起来像这样

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

< br>
,successShowDelay:'4000'

,stripHTML:true

请确保将完整网址路径放在BAT文件夹中,就像我以粗体显示,这将会解决你的问题。
将您的网站名称替换为您的实际网址,您可以很好地去...

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...

这篇关于如何从我购买的templatemonster模板设置联系表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆