开发者

How to redirect users after posting a comment

I want to forward users to a particular URL after posting a comment. I created the post action like this

$referer = $_SERVER['HTTP_REFERER'];
$explode = explode('?posted_on',$referer);
$send_back_url = $explo开发者_StackOverflow社区de[0]."?posted_on=".$post_id;

This works fine in when the referer URLs are in the following format

  • www.xyz.com
  • www.xyz.com?posted_on=123

But its not working when the referer URL is like

  • www.xyz.com?post=12

because its trying to forward to

  • www.xyz.com?post=12?posted_on=123 .

Actually it should forward to

  • www.xyz.com?post=12&posted_on=123


Use

  • parse_url to split the URL into its components
  • parse_str to parse the query component.
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜