3 Replies - 1696 Views - Last Post: 05 May 2009 - 04:51 AM Rate Topic: -----

#1 denemante   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 22-April 09

redirect to thank you page upon submit when posting to remote URL

Post icon  Posted 22 April 2009 - 03:54 PM

Hey everyone - I'm at my wit's end. I'm not sure what I'm trying to do is possible.

Anyway, I have a simple 6 field form on a .htm page. I'm posting this data to a remote URL I'm not in control of, and that part works fine. However, I need the user to be redirected to a thank-you.htm page on my servers.

I've made this work easily when I'm in control of the page/script the form is posting to, because with that, you can specify for it to look for a hidden redirect value back on the form. But again, I'm not in control of this page being posted to.

I did a window.open javascript trick and can in fact get my thank-you page to open upon submission as a new window - but the original window also remains open where it's replaced by a blank page with the URL in the address bar of the page I'm posting to.

Most importantly - there is going to be analytics and other tracking data on my thank-you page (affiliates will be credited for driving the traffic to me). So I'm fearful that using javascript at all for the redirect might kill the referrer data.

So in closing, I'm praying that there is some simple way to just post all data to this remote URL, and in tandem, have my thank-you page appear in the same window where it will still track the affiliate referrer data.

THANK YOU, THANK YOU in advance for your help! I value your time...Dan

Is This A Good Question/Topic? 0
  • +

Replies To: redirect to thank you page upon submit when posting to remote URL

#2 Martyr2   User is offline

  • Programming Theoretician
  • member icon

Reputation: 5283
  • View blog
  • Posts: 14,105
  • Joined: 18-April 07

Re: redirect to thank you page upon submit when posting to remote URL

Posted 22 April 2009 - 10:10 PM

Well there isn't a way to do it in PHP but another javascript option for you is to use an ajax call to the other persons form. The idea is that you fill out your form, when they hit submit you have javascript which, in the background, submits the data via an ajax call to their link. They will process the request and the output they show will then come back to your script as a response. You can validate this response and if it contains something that tells you it was a success, you can load the thank you page in the window.

It is not that hard. Below I have posted a link which will step you through a working example to show you the parts of how this would work.

W3Schools AJAX Tutorial Example

Click the next button on each page to move to the next piece of code. You can stop when it reads "server side code" because obviously that is someone else. But pay special attention to the page that talks about the onreadystatechange functionality. This will handle the request back from this third party page you are submitting to. Its response is what you will check for success and then redirect the user to the thank you page.

Hope this helps! Enjoy!

"At DIC we be AJAX form submitting code ninjas... we have been thinking of starting a match a geek dating service, but then realized that when it comes to matching for love, geeks == epic fail" :snap:
Was This Post Helpful? 1

#3 nick1200   User is offline

  • Php Coder
  • member icon

Reputation: -19
  • View blog
  • Posts: 922
  • Joined: 21-March 09

Re: redirect to thank you page upon submit when posting to remote URL

Posted 04 May 2009 - 05:14 PM

can u show some of your code the script ?




you could allways use

if($session your using){
		 header("Location: /memberspage.htm");





if its a login page or regster page it should have a session

$something it should be called


i ent giving u code just keping your out :)

look at the page were the button is there should be a session

well a $then a word <--


at the bottom of the script add

if($add it herel){
		 header("Location: /thankyoupage.htm");






i just tryed to teach you that on most pages there are sessions on login regster anything with a button on :P

u just got to find it and replace the code


:^:
Was This Post Helpful? 0
  • +
  • -

#4 Wimpy   User is offline

  • R.I.P. ( Really Intelligent Person, right? )
  • member icon

Reputation: 159
  • View blog
  • Posts: 1,038
  • Joined: 02-May 09

Re: redirect to thank you page upon submit when posting to remote URL

Posted 05 May 2009 - 04:51 AM

The AJAX solution previously presented would be the sweetest one but there might be another since you mentioned opening a new window with your "thank you"-page. You could send the form request through a new window (or something) and close the new window when it has finished loading. :)

function SendRequest()
{
	var requestWindow = window.open(params);

	//Implementation to send the request

	requestwindow.onload = new function() 
	{
		requestwindow.close();
	}
}


W3Schools window.open tutorial

I have not tested this yet, so I leave that up to you!

Hope it helps! :)



View Postdenemante, on 22 Apr, 2009 - 02:54 PM, said:

Hey everyone - I'm at my wit's end. I'm not sure what I'm trying to do is possible.

Anyway, I have a simple 6 field form on a .htm page. I'm posting this data to a remote URL I'm not in control of, and that part works fine. However, I need the user to be redirected to a thank-you.htm page on my servers.

I've made this work easily when I'm in control of the page/script the form is posting to, because with that, you can specify for it to look for a hidden redirect value back on the form. But again, I'm not in control of this page being posted to.

I did a window.open javascript trick and can in fact get my thank-you page to open upon submission as a new window - but the original window also remains open where it's replaced by a blank page with the URL in the address bar of the page I'm posting to.

Most importantly - there is going to be analytics and other tracking data on my thank-you page (affiliates will be credited for driving the traffic to me). So I'm fearful that using javascript at all for the redirect might kill the referrer data.

So in closing, I'm praying that there is some simple way to just post all data to this remote URL, and in tandem, have my thank-you page appear in the same window where it will still track the affiliate referrer data.

THANK YOU, THANK YOU in advance for your help! I value your time...Dan

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1