所以我基本上试图创建一个简单的摄影作品集网站,并决定也放入一个联系页面。现在我正在尝试使用php构建一个基本的电子邮件提交表单但是当我在网页中输入值时,值消失了,但我没有收到任何电子邮件。我想知道我的代码中的原因是否有问题,或者我是否必须将网页变成网站才能发送电子邮件。
更多信息:我使用xampp测试php代码,我的文件目录是:C:\ xampp \ htdocs,htdocs内部是一个名为" Photo Website"它有我的所有网页和图片。
我使用http://localhost/Photo%20Website/Contact.php通过localhost运行它并获得了
警告:mail():" sendmail_from"未设置在php.ini或custom" From:" C:\ xampp \ htdocs \ Photo Website \ Contact.php 中缺少标题 46
<!DOCTYPE html>
<html ng-app>
<head>
<meta charset="UTF-8">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.7/angular.min.js">
</script>
<link rel="stylesheet" type="text/css" href="webpage.css">
</head>
<div id="nav">
<ul>
<li><a href="Contact.php"> Contact </a></li>
<li><a href="AboutMe.html"> About Me </a></li>
<li><a href="Business.html"> Business </a></li>
<li><a href="Street.html"> Street </a></li>
<li><a href="Nature.html"> Nature </a></li>
</ul>
<p id="logo"><a href="webpage.html"> Icyportraitsgta </a></p>
</div>
<div id="description">
<!-- Creating the contact forms using HTML !-->
<form method="post" name="emailform" action="Contact.php">
Enter Name: <input type="text" name="name"> <br>
Enter Email: <input type="text" name="email"> <br>
Message: <textarea name="message"></textarea> <br>
<input type="submit" value="Send">
</form>
<!-- Assigned variables using php and used POST !-->
<?php
$name = $_POST['name'];
$visitor_email = $_POST['email'];
$message = $_POST['message'];
?>
<!-- Using the above php variables to compose an email message !-->
<?php
$email_from = 'alihaider2011@live.ca';
$email_subject = "New Form submission";
$email_body = "You have received a new message from the user $name.\n".
"Here is the message:\n $message";
?>
<!-- php code to send the email !-->
<?php
$to = "dutchland2013@hotmail.com";
$headers = "From: $email_from \r\n";
$headers = "Reply-To: $visitor_email \r\n";
mail($to, $email_subject,$email_body, $headers);
?>
</div>
</body>
</html>