www.webdeveloper.com
Results 1 to 2 of 2

Thread: Submit form and show thank you in same popup window

  1. #1
    Join Date
    Jul 2010
    Posts
    50

    Submit form and show thank you in same popup window

    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:

    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;
    	});
    Now once the form is submitted PHP kicks in to email the form data as plain text. Here is the PHP:-

    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';


    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.

    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!

  2. #2
    Join Date
    May 2003
    Posts
    599
    It must be programmed to close automatically. If you want the window to stay open, why not just use a window.open() call? Is there some reason for using jquery to open a form window?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles