views:

25

answers:

2

I have Email Newsletter on the Common Footer file whch is displayed all ove the site, I have Email Newsletter section in footer.

Now I want the newsletter input email to be processed and and return to the same page from where news letter has been subscribed. Also I do not have the permission to redirect the form to footer.php.

Please suggest some idea to make it happen

+1  A: 
$prev_page = $_SERVER['HTTP_REFERER'];
header("Location: $prev_page");
exit;
sathia
Thanks Brother Sathia, I have already tried with this... and it works
OM The Eternity
+1  A: 

If I understand correctly you have a footer on every page with a link like this: (correct me if I'm wrong)

<div id="footer">
    <a href="/newsletter/subscribe.php">Subscribe to newsletter</a>
</div>

Let's say you're on a page with url

/article/20100924

and you want to go back to that page after processing /newsletter/subscribe.php

As usual there are several possible answers to this.

If configured correctly there should be a $_SERVER['HTTP_REFERER'] variable in the server array pointing back to the page where the click originated you could use that, and after processing the form simply put

header('Location: '.$_SERVER['HTTP_REFERER']);

at the end of /newsletter/subscribe.php

If you don't trust $_SERVER['HTTP_REFERER'] to be correct you could put the originating page into the link url like this:

<a href="/newsletter/subscribe.php?backurl=%2Farticle%sF20100924">
    Subscribe to newsletter
</a>
thomasmalt
grt I Used the Second Idea.. :)
OM The Eternity
I found you more helping as you are available different solution...
OM The Eternity
and why should you trust $backurl?
sathia
@sathia You shouldn't really, because any script kiddie can change the backurl variable to be whatever. So at the very least an url parameter should be testet very rigorously.
thomasmalt