我有一个带有 amp-form 组件的 AMP 站点,由于某种原因无法提交表单。控制台错误https://prnt.sc/shu7i0和网络错误https://prnt.sc/shu85g。您还可以在此处查看实时站点https://frontlinewebtech.com/traderharian/。请帮忙
这是我的html
<form class="subscribe-form flex flex-middle" method="POST" action-xhr="/mail.php" target="_top">
<div class="form-control">
<input type="email" required name="email" placeholder="Alamat email">
</div>
<button class="btn-subscribe" type="submit">Daftar</button>
</form>
这是我的PHP
<?php
if(!empty($_POST)){
$email = $_POST['email'];
$formcontent=" From: $email";
$recipient = "bishnu051@gmail.com";
$subject = "email from website";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
$domain_url = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]";
header("Content-type: application/json");
header("Access-Control-Allow-Credentials: true");
header("Access-Control-Allow-Origin: ". str_replace('.', '-','https://frontlinewebtech.com/'));
header("AMP-Access-Control-Allow-Source-Origin: " . $domain_url);
header("Access-Control-Expose-Headers: AMP-Access-Control-Allow-Source-Origin");
header("AMP-Redirect-To: https://example.com/index.html");
header("Access-Control-Expose-Headers: AMP-Redirect-To, AMP-Access-Control-Allow-Source-Origin");
echo json_encode(array('name' => $name));
exit;
}
?>