联系表格发送空

时间:2016-10-17 15:47:44

标签: javascript php html json

我在我的网站上有一个联系表格,当我发送表格时我会变空 电子邮件。我的意思是我看到邮件的内容,但我没有看到参数。 这是联系表格:

contact.php

<div class="status alert alert-success" style="display: none"></div>
<form id="main-contact-form" enctype='application/json' class="contact-form" name="contact-form" method="post" action="sendemail.php" role="form">
    <div class="row">
        <div class="col-sm-5">
            <div class="form-group">

                <input type="text" name="fullname" class="form-control" required="required" placeholder="Full Name">
            </div>
            <div class="form-group">
                <input type="text" name="phone" class="form-control" placeholder="Phone Number">
            </div>
            <div class="form-group">
                <input type="email" name="emailaddress" class="form-control" required="required" placeholder="Email Address">
            </div>
            <div class="form-group">
                <input type="submit" class="btn btn-primary btn-lg" value="SEND">
            </div>
        </div>
        <div class="col-sm-7">
            <textarea name="message" id="message" required class="form-control" rows="8" placeholder="Message"></textarea>
        </div>
    </div>
</form>

这是行动的文件:

sendemail.php

<?php
header('Content-type: application/json');
$status = array(
    'type'=>'success',
    'message'=>'Email Sent!'
);

$name = htmlspecialchars($_REQUEST['fullname']); 
$email = htmlspecialchars($_REQUEST['emailaddress']); 
$phone = htmlspecialchars($_REQUEST['phone']); 
$subject = 'MSG FROM '. $name; 
$message = htmlspecialchars($_REQUEST['message']); 

$email_from = $email;
$email_to = 'contact@tazminu.co.il';

$body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'Phone: ' . $phone . "\n\n" . 'Message: ' . $message;

$success = @mail($email_to, $subject, $body, 'From: <'.$email_from.'>');

echo json_encode($status);
die;

?>

请帮助:(

0 个答案:

没有答案