php - 无法让我的联系表实际工作
问题描述
一般来说,我对编码很陌生,刚刚开始尝试将 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");
}
解决方案
推荐阅读
- c# - 通过后端代码更新防火墙规则
- python - 如何在 python 中向现有列表添加或更新信息
- java - Java:Selenium WebElements 和 AssertThat 给出不正确的结果
- javascript - 选择组件以在打开后将组件移到下方
- ios - NSString initWithCoder,DequeueReusableCell 处的内存泄漏
- laravel-backpack - 在 store 函数中获取最后一个插入 id
- android - 我收到此错误。当我尝试使用 facebook 登录我的应用程序时:将您登录到此应用程序时出错
- c - 如何在 C 中使用双宏
- c - 不使用 clflush 逐出缓存行
- azure-ad-b2c - Azure AD B2C 自定义策略注册,仅使用预先填写的会员编号和电子邮件