开发者

How to redirected to current page after processing the code and its result on other page?

I have Email Newsletter on the Common Footer file whch is displayed all ove the site, I have Email Newsletter section i开发者_JAVA百科n 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


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>


$prev_page = $_SERVER['HTTP_REFERER'];
header("Location: $prev_page");
exit;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜