Hi all,
This is a mix of jquery and PHP so let me know if Im in the wrong place.
Basically I have a button saying click here to request a sample. This button when clicked opens a popup window with a form to fill out. This popup is generated by this bit of jquery:
Now once the form is submitted PHP kicks in to email the form data as plain text. Here is the PHP:-Code:// Pop up samples request form $('a.login-window').click(function() { //Getting the variable's value from a link var formBox = $(this).attr('href'); //Fade in the Popup $(formBox).fadeIn(300); //Set the center alignment padding + border see css style var popMargTop = ($(formBox).height() + 24) / 2; var popMargLeft = ($(formBox).width() + 24) / 2; $(formBox).css({ 'margin-top' : -popMargTop, 'margin-left' : -popMargLeft }); return false; }); // When clicking on the button close or the mask layer the popup closed $('a.close').live('click', function() { $('.login-popup').fadeOut(300 , function() { }); return false; });
I normally just use the $sent variable to display a message depending on the value. However once the form is submitted the popup window is closed - so the message is not shown.PHP Code:$sent = '';
if (($_POST['fname'] != ''))
{
//Send the email
$textEmail = file_get_contents("emails/samples.txt");
$textEmail = str_replace("|FNAME|",$_POST['fname'],$textEmail);
$textEmail = str_replace("|ADDRESS|",$_POST['address'],$textEmail);
$textEmail = str_replace("|POSTCODE|",$_POST['postcode'],$textEmail);
$textEmail = str_replace("|EMAIL|",$_POST['email'],$textEmail);
$textEmail = str_replace("|PRODUCT|",$_POST['product'],$textEmail);
$to = "email@myemail.co.uk";
$subject = "Samples request";
$headers = "From: email@myemail.co.uk"."\r\n"."X-Mailer: PHP/".phpversion();
ini_set("sendmail_from", "email@myemail.co.uk");
mail($to,$subject,$textEmail,$headers, '-femail@myemail.co.uk');
$sent = 'y';
}
How can I make the popup window stay open after the form has been submitted and show a thank you message? Or show a thank you message in a new popup window?
Thank you kind humans!


Reply With Quote

Bookmarks