在 php 退出意图弹出窗口中发布电子邮件表单

Email form posting in php exit intent pop up

问题:电子邮件提交后弹出窗口关闭。

目标:在提交电子邮件表单后将用户留在弹出窗口中,以便 he/she 可以看到下载 link。

退出意图弹出窗口效果很好,但我无法理解表单 post。我不使用 jQuery 或其他依赖项,但我欢迎 js。你能帮忙吗?

代码:

<?php
$cookie_name = "TSBCookie";
$cookie_value = "TSB";
setcookie($cookie_name, $cookie_value, time() + (86400 * 1), "/");
if(!isset($_COOKIE[$cookie_name])) {
echo "

<div id='exit-intent' class='exit-intent'>
<a href='/test/#download' class='close'>&times;</a>
<h3 class='margin-t190 margin-b40'>Want Free Pages?</h3>

<form id='exitemailform' class='exitmailform' method='post' action='/'>
<input type='hidden' name='form-type' value='contact'/>
<fieldset>
<p><label>
<input required class='subscribeform' type='email' name='email' placeholder='Your email here' aria-label='email' multiple>
</label></p>

<div class='controls'>
<input class='btn2 margin-t10' type='submit' name='submitexit' value='Download'>
</div>
</fieldset>

</form>

</div>
<a href='/test/#download' class='close-exit-intent'></a>

";
} else {
echo "";
}
?>

<?php
if(isset($_POST['submitexit'])){
    $submit = htmlentities($_POST['submitexit']);
    $date = $_POST['date'];
    $link_address = "https://example.com/1.pdf";
    $receive = "<a class=un href=".$link_address." download target=_blank rel=noopener>Click to receive your free pages</a>!";
echo "<style>#exitemailform{display:none}</style><p style='font-size:30px'>" . $receive . "</p>";
}
?>

我在不让用户进入 php 弹出窗口的情况下让它工作。提交表单后,用户将在网站内重定向。