I am using this PHP
code to send the form information to email after submitting the form it is redirecting to thank you page,
But due to some issue this is not working for mobile devices, on desktop after submitting the form its redirecting to thank you page but the same time if I am hitting the URL from mobile devices it's not redirecting to thank you but mail functioning working fine.
I have uploaded file to some other server and after submitting the form thank you page is on some other server.
<?php
header("access-control-allow-credentials:true");
header("access-control-allow-headers:Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token");
header("access-control-allow-methods:POST, GET, OPTIONS");
if($_SERVER['HTTP_ORIGIN']) {
$origins = $_SERVER['HTTP_ORIGIN'];
} else if($_SERVER['HTTP_REFERER']) {
$origins = $_SERVER['HTTP_REFERER'];
}
header("access-control-allow-origin:".$origins);
header("access-control-expose-headers:AMP-Redirect-To,AMP-Access-Control-Allow-Source-Origin");
header("amp-access-control-allow-source-origin:".$origins);
header("Content-Type: application/json");
$redirect_url = "https://ashsri.com";
//give to email id and subject
$to = 'asheeshsrivastav89@gmail.com';
$subject = 'Form Submission Deatis';
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
$message="<table>";
$message.="<tr><td> Name :</td><td>".addslashes($_POST["input_12"])."</td></tr>";
$message.="<tr><td> Surname : </td><td>".addslashes($_POST["input_16"])."</td></tr>";
$message.="<tr><td> Phone :</td><td>".addslashes($_POST["input_6"])."</td></tr>";
$message.="<tr><td> Email :</td><td>".addslashes($_POST["input_4"])."</td></tr>";
$message.="</table>";
$mailsent="";
$mail='';
if(mail($to,$subject,$message,$headers))
{
$mailsent="Thank you for your message. It has been sent.";
$mail=true;
header("AMP-Redirect-To: ".$redirect_url);
header("Access-Control-Expose-Headers: AMP-Redirect-To, AMP-Access-Control-Allow-Source-Origin");
}
else
{
$mailsent="There was an error trying to send your message. Please try again later.";
$mail=false;
}
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");
}
$returnArray=array("mailSent"=>$mail,"message"=>$mailsent);
$returnstring=json_encode($returnArray);
echo $returnstring;
Can anybody help me out with this??