我有一个 AMP 表单,但由于某种原因,它在提交时出错

I have an AMP form but for some reason it has error while submitting

我有一个带有 amp-form 组件的 AMP 网站,但由于某种原因无法提交表单。 控制台 https://prnt.sc/shu7i0 and network error https://prnt.sc/shu85g. You can also take a look at the live site here 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;
}
?>

我检查了你所有的附件,我发现这个错误是由于 406 "Not Acceptable" 原因造成的。

在此服务器上找不到所请求资源的适当表示。此错误由 Mod_Security.

生成

复制以下文本并将其粘贴到域根目录下的 .htaccess 文件中。

<IfModule mod_security.c> SecFilterEngine Off SecFilterScanPOST Off </IfModule>

或检查您的 Apache mod_security 配置。

useful link