Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
152 views
in Technique[技术] by (71.8m points)

html - Email form posting in php exit intent pop up

Issue: The popup closes after email submission.

Goal: To keep the user inside the popup after submitting the email form, so he/she can see the download link.

The exit intent pop up is working great but I cannot figure out the form post. I don't use jQuery or other dependencies but I welcome js. Can you please assist?

Code:

<?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>";
}
?>
question from:https://stackoverflow.com/questions/66049175/email-form-posting-in-php-exit-intent-pop-up

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I made it work without keeping the user inside the php pop up. after the form submission the user is redirected inside the website.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...