简体   繁体   中英

jQuery PopUp from Form Submit (via .php email form)

I'm having trouble figuring out how to have a nice popup that thanks the user for their form submission. On my hosting site, I'm using a .php page that sends me an email (form mail feature) after the form has been submitting. In my website code, I have a redirect to a thank you page. But, I'm not sure how to have the popup go to the redirect thank you page (thankyou.html) so I can style it (instead of using the default browser popup). I still want to make sure the .php file is used to send to my gmail account.

Form in my website:

<div id="container-footer">
<form action="gdform.php" method="post" id="contact">
<fieldset class="wrapper"><legend>Contact</legend> 
<input type="hidden" name="subject" value="Submission" />
<input type="hidden" name="redirect" value="/thankyou.html" />
<ul class="group">
<li class="name"><label for="name">Your Name</label> <input id="name" name="name" type="text" /></li>
<li class="email"><label for="email">Your Email</label> <input id="email" name="email" type="email" /></li>
<li class="message"><label for="message">Say Hello</label><textarea id="message" name="message"></textarea></li>
</ul>
<input class="send" name="submit" type="submit" value="Send" />


</fieldset>
</form>


<footer class="wrapper" id="colophon">
<p>&copy;2014 all rights reserved.</p>
</footer>
</div>

gdform.php

<?php
$request_method = $_SERVER["REQUEST_METHOD"];
if($request_method == "GET"){
  $query_vars = $_GET;
} elseif ($request_method == "POST"){
  $query_vars = $_POST;
}
reset($query_vars);
$t = date("U");

$file = $_SERVER['DOCUMENT_ROOT'] . "/../data/gdform_" . $t;
$fp = fopen($file,"w");
while (list ($key, $val) = each ($query_vars)) {
 fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\n");
 fputs($fp,"$val\n");
 fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\n");
 if ($key == "redirect") { $landing_page = $val;}
}
fclose($fp);
if ($landing_page != ""){
header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");
} else {
header("Location: http://".$_SERVER["HTTP_HOST"]."/");
}


?>

thankyou.html (I'd like this in the nice jQuery or other than browser popup)

<h1>THANK YOU!</h1>

<p>Thank you for contacting me. I'll get back with you as soon as possible.</p>

You could probably make the popup using Jack Moore's jQuery Modal . Then, you can call that JS function with your PHP code .

I'm not the best in this field, so someone else can probably give a better, more definitive answer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM