Pulse CMS - 联系表格

时间:2016-10-18 15:44:38

标签: php content-management-system contact-form pulse

我在“http://missdcall.co.uk”处制作了一个网站,并使用Pulse CMS在底部添加了联系表单。

联系表格继续返回错误声明:“很抱歉,我们的邮件服务器似乎没有回应,很抱歉给您带来不便!”

据我所知,所有设置都正确。我在代码中看不到任何错误。

如果有人有任何建议,我们将不胜感激!

请在下面找到相关文件......

了home.txt

<div class="col-sm-6">
            <form id="form_1" novalidate>
                <div class="form-group">
                    <label>
                        Name
                    </label>
                    <input id="name" class="form-control" required />
                </div>
                <div class="form-group">
                    <label>
                        Email
                    </label>
                    <input id="email" class="form-control" type="email" required />
                </div>
                <div class="form-group">
                    <label>
                        Message
                    </label><textarea id="message" class="form-control" rows="4" cols="50" required></textarea>
                </div> 
                <button class="bloc-button btn btn-d btn-lg btn-block" type="submit">
                    Send
                </button>
            </form>
        </div>

form_1.php

<?php   
if(empty($_POST['name']) && strlen($_POST['name']) == 0 || empty($_POST['email']) && strlen($_POST['email']) == 0 || empty($_POST['message']) && strlen($_POST['message']) == 0)
{
    return false;
}

$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];

$to = 'hello@missdcall.co.uk'; // Email submissions are sent to this email

// Create email 
$email_subject = "Message from miss'd call.";
$email_body = "You have received a new message. \n\n".
              "Name: $name \nEmail: $email \nMessage: $message \n";
$headers = "MIME-Version: 1.0\r\nContent-type: text/plain; charset=UTF-8\r\n";  
$headers .= "From: joe@j-col.com\n";
$headers .= "Reply-To: $email"; 

mail($to,$email_subject,$email_body,$headers); // Post message
return true;            
?>

formHandler.js

$(function()
{var successMsg = "Your message has been sent."; // Message shown on success.
var failMsg = "Sorry it seems that our mail server is not responding, Sorry for the inconvenience!"; // Message shown on fail.

$("input,textarea").jqBootstrapValidation(
{
    preventSubmit: true,
    submitSuccess: function($form, event)
    {
        if(!$form.attr('action')) // Check form doesnt have action attribute
        {
            event.preventDefault(); // prevent default submit behaviour

            var processorFile = "./includes/"+$form.attr('id')+".php";
            var formData = {};

            $form.find("input, textarea, option:selected").each(function(e) // Loop over form objects build data object
            {       
                var fieldData =  $(this).val();
                var fieldID =  $(this).attr('id');

                if($(this).is(':checkbox')) // Handle Checkboxes
                {
                    fieldData = $(this).is(":checked");
                }
                else if($(this).is(':radio')) // Handle Radios
                {
                    fieldData = $(this).val()+' = '+$(this).is(":checked");
                }
                else if($(this).is('option:selected')) // Handle Option Selects
                {
                    fieldID = $(this).parent().attr('id');
                }

                formData[fieldID] = fieldData;      
            });

            $.ajax({
                url: processorFile,
                type: "POST",
                data: formData,
                cache: false,
                success: function() // Success
                {  
                    $form.append("<div id='form-alert'><div class='alert alert-success'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button><strong>"+successMsg+"</strong></div></div>");      
                },
                error: function() // Fail
                {
                    $form.append("<div id='form-alert'><div class='alert alert-danger'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button><strong>"+failMsg+"</strong></div></div>");  
                },
                complete: function() // Clear
                {
                    $form.trigger("reset");
                },
            });
        }
     },
     filter: function() // Handle hidden form elements
     {
         return $(this).is(":visible");
     },
 });
});

0 个答案:

没有答案