希望这类问题得到很多次的回答,但我已经完成了大部分问题并且没有找到任何解决方案,请帮助解决我的问题。
我有一个html表单
<form id="main-contact-form" class="contact-form" enctype="text/plain" name="contact-form" method="post" action="sendemail.php">
<div class="col-sm-5 col-sm-offset-1">
<div class="form-group">
<label>Name *</label>
<input type="text" name="vname" id="vname" class="form-control" required="required">
</div>
<div class="form-group">
<label>Email *</label>
<input type="email" name="vemail" id="vemail" class="form-control" required="required">
</div>
<div class="form-group">
<label>Phone</label>
<input type="text" class="form-control">
</div>
<div class="form-group">
<label>Company Name</label>
<input type="text" class="form-control">
</div>
</div>
<div class="col-sm-5">
<div class="form-group">
<label>Subject *</label>
<input type="text" name="vsubject" id="vsubject" class="form-control" required="required">
</div>
<div class="form-group">
<label>Message *</label>
<textarea name="vmessage" id="message" required="required" class="form-control" rows="8"></textarea>
</div>
<div class="form-group">
<button type="submit" name="submit" class="btn btn-primary btn-lg" required="required">Submit Message</button>
</div>
</div>
</form>
这是我发送电子邮件的PHP代码
<?php
header('Content-type: application/json');
$status = array(
'type'=>'success',
'message'=>'Thank you for contact us. As early as possible we will contact you '
);
$name = @trim(stripslashes($_POST['vname']));
$email = @trim(stripslashes($_POST['vemail']));
$subject = @trim(stripslashes($_POST['vsubject']));
$message = @trim(stripslashes($_POST['vmessage']));
$email_from = $email;
$email_to = 'myemail';//replace with your email
$body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'Subject: ' . $subject . "\n\n" . 'Message: ' . $message;
$success = @mail($email_to, $subject, $body, 'From: <'.$email_from.'>');
echo json_encode($status);
die();
提供数据并点击提交发送电子邮件但接收空白数据
名称:
电子邮件:
主题:
消息:
(未知发件人)
(无主题) - 姓名:电子邮件:主题:消息:
请帮助我,因为我是PHP的新手
我正在使用带有Apache的CENTOS网络面板