Php 从表单发送包含数据的电子邮件
我有简单的接触盒问题。我想把表格中的信息发送到我的电子邮件中 已尝试打开和关闭注册表全局设置(.httaces),尝试使用简单的$formname和$u POST['formname'],但仍然收到没有表单信息的电子邮件Php 从表单发送包含数据的电子邮件,php,html,forms,contact-form,Php,Html,Forms,Contact Form,我有简单的接触盒问题。我想把表格中的信息发送到我的电子邮件中 已尝试打开和关闭注册表全局设置(.httaces),尝试使用简单的$formname和$u POST['formname'],但仍然收到没有表单信息的电子邮件 <?php if ($action == "send"){//isset wyslij //if (!$name || !$email || !$phone || !$enquiry) { //$problem = TRU
<?php
if ($action == "send"){//isset wyslij
//if (!$name || !$email || !$phone || !$enquiry) {
//$problem = TRUE;
//echo("<p>You have to fill all form.</p>");
//}
if (!$problem){
$name = $_POST['name'];
$data = date("d.m.y");
$message = "
<p>Name: $name</p>
<p>Phone: $phone</p>
<p>Email: $email</p>
<br>
<p>Enquiry: $enquiry</p>";
$od = "blabla@email.com";
$content = $message;
$header = "From: $od \r\n";
$header .= 'MIME-Version: 1.0' . "\r\n";
$header .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
(mail('myemail@gmail.com', 'New message from website Angelzena', $content, $header));
echo("<br><p>Message has been sent.</p>");
}else{
echo("<p>Try <a href=contact.php>again</a></p>");
}
}
?>
<form action="contact.php?action=send" method="post" enctype="text/plain">
<label for="name">Name</label><input type="text" name="name" /></br></br>
<label for="email">Email</label><input type="text" name="email" /></br></br>
<label for="phone">Phone</label><input type="text" name="phone" /></br></br>
<label for="enquiry">Enquiry</label><textarea name="enquiry" cols="20" rows="10"></textarea></br></br>
<input type="submit" id="contact_button" value="Send" />
</form>
名字
电子邮件
电话
询问
发布表单时,enctype
属性应为application/x-www-form-urlencoded
或multipart/form data
PHP不处理以
text/plain
形式发布的表单。除非您遗漏了脚本的一部分,否则您的脚本不会获得除name
之外的任何输入字段。忘记注册全局!你绝对不应该使用它。通过$\u POST['email']
访问您的表单值,我尝试过这样的$name=$\u POST['name'];,但我在电子邮件中没有得到名字的价值,所以这仍然不起作用。很好的发现。因为没有文件组件,所以应该省略enctype
。