php邮件处理程序显示代码

时间:2014-01-26 01:13:23

标签: php html forms

我正在使用以下代码创建联系人邮件表单。但每当我点击提交按钮时,它只会在浏览器中显示下面的代码。我不确定我做错了什么。

<?php
$to = 'email@website.com';
$Name = $_POST['name'];
$email = $_POST['mail'];
$message = $_POST['comment'];
$headers = 'From: '.$name;
mail($to, $subject, $message, $headers);
exit('Your message has been sent.')
?>


<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>Welcome</title>
<link href="layout-styles.css" rel="stylesheet" type="text/css" media="screen" />
</head>

<body>
<div id = "form">
<form action="contact-us.php" method="post">
Name:<br>
<input type="text" name="name" id = "name" placeholder="your name"><br>
E-mail:<br>
<input type="text" name="mail" id = "mail" placeholder="your email"><br>
Comment:<br>
<textarea type="text" name="comment" id ="mail"placeholder="your comment" rows = 10 cols = 50></textarea><br><br>
<input type="submit" value="Send">
<input type="reset" value="Reset">
</div>
</form>

0 个答案:

没有答案