0

I'm trying to redirect my PHP contact form to a separate 'Thank You' Page to better track our leads coming in. I just need to know where to put the URL and how. I'm no expert in PHP and would LOVE the help. This isn't all of the code for the form, but it's the snippet where I felt it would be plugged in (Assuming it will replace "Thanks! Your email was successfully sent.")

Thank YOU! Danielle

    if(!hasError) {
            var formInput = jQuery(this).serialize();
            jQuery.post(jQuery(this).attr( 'action'),formInput, function(data){
                jQuery( 'form#contactForm').slideUp( "fast", function() {
                    jQuery(this).before( '<p class="tick"><?php _e( '<strong>Thanks!</strong> Your email was successfully sent.', 'woothemes' ); ?></p>' );
                });
            });
        }

        return false;

    });
});
//-->!]]>
</script>
  • 2
    You use AJAX to post the data.. but you want to go to a different URL after submission? Seems a bit pointless to use AJAX. Anyways.. look at something like `window.location.href = '...'`. – putvande Jul 11 '14 at 13:16
  • 1
    Redirecting in PHP: http://stackoverflow.com/questions/768431/how-to-make-a-redirect-in-php Redirecting in JavaScript: http://stackoverflow.com/questions/503093/how-can-i-make-a-redirect-page-in-jquery-javascript – David Jul 11 '14 at 13:17

1 Answers1

1

You can add a redirect with Javascript

if(!hasError) {
    var formInput = jQuery(this).serialize();
    jQuery.post(jQuery(this).attr( 'action'),formInput, function(data){
        jQuery( 'form#contactForm').slideUp( "fast", function() {
            window.location.href = 'http://www.google.com';
        });
    });
}
Marvin
  • 157
  • 14