对于一般的编码我还是很陌生,只是开始尝试将PHP用于uni项目。
我制作了一个非常简单的HTML联系人表单,并且没有打扰它的样式(因为这只是测试) 我的问题现在是,我尝试使它实际通过发送电子邮件。 PHP。 联系人表单本身可以使用,但是不会将电子邮件发送到我在PHP中选择的邮件中
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title> Contact form tutorial </title>
</head>
<body>
<main>
<p> SEND E-MAIL </p>
<form class="contact-form" action="contactform.php" method="post">
<input type="text" name="name" placeholder="Full name">
<input type="text" name="mail" placeholder="Your e-mail">
<input type="text" name="subject" placeholder="Subject">
<textarea name="message" placeholder="Message"></textarea>
<button type="submit" name="submit"> SEND MAIL </button>
</form>
</main>
</body>
</html>
<?php
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$subject = $_POST['subject'];
$mailFrom = $_POST['mail'];
$message = $_POST['message'];
$mailTo = "hse-g01@haarslev-esport.dk";
$headers = "From: ".$mailFrom;
$txt = "You have recieved an e-mail from ".$name.".\n\n".$message;
mail($mailTo, $subject, $txt, $headers);
header("Location: index.html?mailsend");
}