提交表单后,只需要重定向到三江源页面之前显示在弹出的变量值

问题描述 投票:0回答:1

我需要重定向他/她的三江源页面之前,显示弹出用户。在弹出我需要证明我已经生成的随机码。弹出包含“继续”按钮,点击之后,弹出窗口应关闭,然后重定向到三江源页面。

配置:

include("connectiondb.php");

# LIST EMAIL ADDRESS
$recipient = "[email protected]";

# SUBJECT (Subscribe/Remove)
$subject = "Hello ";

# RESULT PAGE
$location = "/thank-you.php";

## FORM VALUES ##

$sender = "[email protected]";

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" );

其实这项工作的目的是为了提供用户一个唯一的代码,他使用后进行进一步处理。

php forms popup
1个回答
0
投票

这是不是最漂亮的解决方案,但你可以使用JavaScript的浏览器弹出一个窗口。

$str_result = 'Hello World!';
echo '<script type="text/javascript">alert(\'' . $str_result . '\' );</script>';

你那种混合后端代码前端的行为,但是这至少会显示您的用户$str_resultvalue。

© www.soinside.com 2019 - 2024. All rights reserved.