0
我創建了一個AMP填表它應該重定向後的形式來感謝頁面:如何重定向到AMP網站的一個單獨的頁面
<form on="tap:my-lightbox" custom-validation-reporting="show-all-on-submit" action-xhr="https://example.com/amp/nextown/test.php" method="post" target="_blank" role="form">
<div class="col-md-12">
<input type="text" class="form-control" name="name" id="lblname" placeholder="Name*" required pattern="\w+\s\w+">
<span visible-when-invalid="valueMissing" validation-for="lblname"></span>
<span visible-when-invalid="patternMismatch" validation-for="lblname">
</span>
</div>
<div class="col-md-12">
<input type="email" class="form-control" name="email" id="lblemail" placeholder="Email Address*" required="text">
<span visible-when-invalid="valueMissing" validation-for="lblemail"></span>
<span visible-when-invalid="typeMismatch" validation-for="lblemail"></span>
</div>
<div class="col-md-12">
<input type="text" class="form-control" name="phone" id="lblphone" placeholder=" Phone Number*" required="text"></div>
<div class="col-md-12 but-mdsubmit">
<input id="popup_sub" type="submit" value="SEND ENQUIRY" >
</div>
</div>
</form>
test.php的代碼:
$domain_url = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]";
$redirect_url = 'https://example.com/amp/nextown/thankyou.amp.html';
if($_POST['name']!="" && $_POST['email']!="" && $_POST['phone']!=""){
$name = $_POST['name'];
$email = $_POST['email'];
$mobile = $_POST['phone'];
$source= "NA";
$medium = "NA";
$campaign = "NA";
$vserv= "NA";
$state="NA";
$city = "NA";
$dialing_code='91';
$country='India';
$project_id ='284';
$client_id ='4';
$ind_project_id='';
$crm_url = "http://exampleapi.com/campaign/fetch_data/".urlencode($name)."/".urlencode($email)."/".urlencode($mobile)."/284/".urlencode($source)."/".urlencode($medium)."/".urlencode($campaign)."/4/NA/NA/".urlencode($dialing_code)."";
if(file_get_contents($crm_url)){
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: https://netbizlabs.com");
header("Access-Control-Expose-Headers: AMP-Access-Control-Allow-Source-Origin");
header("Access-Control-Expose-Headers: AMP-Access-Control-Allow-Source-Origin, AMP-Redirect-To");
header ('AMP-Redirect-To: '.$redirect_url);
//echo json_encode(array('successmsg'=>'My success message. [It will be displayed shortly(!) if with redirect]'));
exit;
}
}
但它沒有重定向,我做錯了,請幫助我,因爲我是AMP網站開發新手。
在此先感謝。
嘗試用下面的代碼,張貼在我的答案,如果不行讓我知道 –