AMP形式问题(非常缓慢)

时间:2019-06-17 10:16:29

标签: amp-html amp-form

单击“发送”时,表单最多需要30秒才能发送。

该表单正在运行,但最终会发送。

如果我检查页面并查看网络以尝试查看正在发生的情况,它将立即按预期发送。正常查看页面时,速度确实很慢。

我不知道是什么原因造成的?还有其他人有类似的问题吗?

我已与托管公司联系,以确认问题是我的解决,而不是服务器问题。

HTML

<form method="post" action-xhr="send-form.php">
Your name:<br>
           <input type="text" name="namee" required  />
           Your telephone number:<br>
            <input type="text" name="phone" required />
            Your email address:<br>
           <input type="text" name="email" required />
           Your message:<br>
           <textarea name="message"></textarea>

            <input type="submit" class="imgcenter" value="" background-image: url(https://www.example.co.uk/img/send.png);"/>
</form>

PHP

<?php
if( !empty($_POST) ){

    $email = $_POST['email'];
    $namee = $_POST['namee'];
    $phone = $_POST['phone'];
    $message = $_POST['message'];

    $formcontent=" From: $email" . "$namee" . "$phone" . "$message";
    $recipient = "hello@example.co.uk";
    $subject = "Enquiry";
    $mailheader = "From: $email \r\n";
    mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");

    $domain_url = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]";
    $redirect_url = 'https://www.example.co.uk/thanks.html'; //-->MUST BE 'https://';

    header("Content-type: application/json");
    header("Access-Control-Allow-Credentials: true");
    header("Access-Control-Allow-Origin: *.ampproject.org");
    header("AMP-Access-Control-Allow-Source-Origin: ".$domain_url);


        if( empty($redirect_url) ){
            header("Access-Control-Expose-Headers: AMP-Access-Control-Allow-Source-Origin");
        }else{
            header("AMP-Redirect-To: ".$redirect_url);
            header("Access-Control-Expose-Headers: AMP-Redirect-To, AMP-Access-Control-Allow-Source-Origin");
        }     
}
?>

0 个答案:

没有答案