我需要向用户显示弹出窗口,然后将其重定向到Thankyou页面。 在弹出窗口中,我需要显示生成的随机代码。弹出窗口包含一个“继续”按钮,单击该按钮后,弹出窗口应关闭,然后重定向到“谢谢”页面。
配置:
include("connectiondb.php");
# LIST EMAIL ADDRESS
$recipient = "forms@brand.com";
# SUBJECT (Subscribe/Remove)
$subject = "Hello ";
# RESULT PAGE
$location = "/thank-you.php";
## FORM VALUES ##
$sender = "support@brandname.com";
if (isset($_POST['Termscheck'])) {
$termsCheck = "Yes";
} else {
$termsCheck = "No";
}
# Generating unique alphanumaric code on each submission
function random_strings($length_of_string)
{
// String of all alphanumeric character
$str_result = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
// Shufle the $str_result and returns substring
// of specified length
return substr(str_shuffle($str_result),
0, $length_of_string);
}
$gcbcode = random_strings(6);
# MAIL BODY
$subscriber_email = $_REQUEST['Email'];
$subscriber_subject = "THANK YOU";
$subscriber_email_data = file_get_contents('/email/queryFormThankyou.html');
# assigning values to email body
$body .= "Name: ".$_REQUEST['Name']." \n";
$body .= "Email: ".$_REQUEST['Email']." \n";
$body .= "Number: ".$_REQUEST['Number']." \n";
$body .= "Company Name: ".$_REQUEST['Companyname']." \n";
$body .= "Industry: ".$_REQUEST['Industry']." \n";
$body .= "Design's Company Name: ".$_REQUEST['DesignCompanyName']." \n";
$body .= "Title of Your design: ".$_REQUEST['Titledesign']." \n";
$body .= "Caption: ".$_REQUEST['Caption']." \n";
$body .= "UniqueFeatures: ".$_REQUEST['UniqueFeatures']." \n";
$body .= "1st preferred medium of communication: ".$_REQUEST['Preferred_medium_one']." \n";
$body .= "2nd preferred medium of communication: ".$_REQUEST['Preferred_medium_two']." \n";
$body .= "Prefer Time to Call: ".$_REQUEST['Meeting_time']." \n";
$body .= "Agrees with Terms and policy: ".$termsCheck." \n";
$body .= "GCP code: ".$gcbppcode." \n";
if($_FILES["file"]["error"]>0)
{
echo "FILE ERROR";
die();
}
$info = pathinfo($_FILES['wordfile']['name']);
$ext = $info['extension']; // get the extension of the file
$newname = time().'.'.$ext;
$target = '../Folder/'.$newname;
// move file to a folder
if (!move_uploaded_file($_FILES["wordfile"]["tmp_name"], $target)) {
// echo "Sorry, there was an error uploading your file.";
// die();
$target = 'No file attached';
}
$body .= "file: ".$target." \n";
if (mysqli_connect_errno()){ echo "Failed to connect to MySQL: " . mysqli_connect_error(); }
else{ $sql = 'insert into abctable (name,email,phone,companyname,industry,DesignCompanyName,Titledesign,Caption,UniqueFeatures,Preferred_medium_one,Preferred_medium_two,meeting_time,agreeWithPolicy,gcp_code,uploaded_file_URL) values ("'.$_REQUEST['Name'].'","'.$_REQUEST['Email'].'","'.$_REQUEST['Number'].'","'.$_REQUEST['Companyname'].'","'.$_REQUEST['Industry'].'","'.$_REQUEST['DesignCompanyName'].'","'.$_REQUEST['Titledesign'].'","'.$_REQUEST['Caption'].'","'.$_REQUEST['UniqueFeatures'].'","'.$_REQUEST['Preferred_medium_one'].'","'.$_REQUEST['Preferred_medium_two'].'","'.$_REQUEST['Meeting_time'].'","'.$_REQUEST['Termscheck'].'","'.$gcbcode.'","'.$target.'")';
mysqli_query($con,$sql);
mysqli_close($con);
}
$headers = "From: " . $sender . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
mail( $recipient, $subject, $body, "From: $sender" ) or die ("Mail could not be sent.");
mail( $subscriber_email, $subscriber_subject, $subscriber_email_data, $headers) or die ("Unable to send email to subscriber");
header( "Location: $location" );
实际上,这项工作的目的是为用户提供一个唯一的代码,供他在后续处理中使用。
答案 0 :(得分:0)
这是不是最漂亮的解决方案,但是在可以使用JavaScript浏览器弹出一个窗口。
:selected="building.id == building"
您是那种混合后端代码前端的行为,但是这至少会显示您的用户$str_result = 'Hello World!';
echo '<script type="text/javascript">alert(\'' . $str_result . '\' );</script>';
值。