gkiar
gkiar

Reputation: 478

Form Submit with Different Redirect Location than Action

Problem:
I have an RSS feed. As some of you may know, RSS feeds do not always update promptly (I'm using FeedBurner) so I'd like to provide the option on my webpage to update the RSS feed. This is a simple process, and I just need to ping an address. The catch is this: I'd like to stay on the initial page, and ideally refresh it.

I've seen some "solutions" around with using hidden iframes, and javascript, Ajax, etc..
What I am wondering is if there is an elegant way to do this using php/html.

Below is a flowchart illustrating exactly how I would like the system to function.

EDIT:
Here is the simple form code which I currently have:

<form action="http://url.to.ping" method="post">
   <input type="submit" value="Refresh" />
</form>

This is a standard form, performing an action on submit. I require now that the browsers destination (as seen from the user) is a different url than that in the action. It is worth noting that the action page is not in my domain, and is not part of a domain which I own or have access to.

Thanks!

Upvotes: 3

Views: 1554

Answers (2)

DannyTheDev
DannyTheDev

Reputation: 4173

What i meant was,

/contactme.php

once they've submitted and come back to the page is there any additional variables like

/contactme.php?thanks=1

basically is there anything to declare they have just submitted and come back to the original page, if so..

You could do;

<?php
if(isset($_GET['thanks']))
{
    $pingServer = file_get_contents('http://www.the.server.to.ping.com/pingit.php');
    unset($pingServer);
}
?> 

at the bottom of the page and it'll just hit that page.

This way you are not relying on JavaScript being enabled and the user is not hopped around multiple URLs.

Upvotes: 1

sdowswell
sdowswell

Reputation: 101

What I have done when I needed the landing page to be different from the processing page is add a JavaScript redirection where one would put their "thanks for filling out my form" material.

So, the code process would be:

  1. user fills out form, clicks submit
  2. server-side validation and processing.
  3. if success then location.href(URL, 0); else do error case
  4. user is redirected to new URL (your refresh page)

Upvotes: 0

Related Questions