Jump to content

[SOLVED] Adding to a URL


Ashoar

Recommended Posts

Just a quick question.

 

How could you add a new page to the end of a URL?

 

For example i have this url:

www.websitehere.com/board.php?forum_num=test

 

Now i have a post.php page which allows a user to insert a post but when i try to add it as a link to the post page i get this url:

www.websitehere.com/post.php

 

So how could i add post.php to the end of the original URL so that it will go to post.php?

 

Thanks

Link to comment
Share on other sites

You can't add a different URL to an existing URL and expect the second URL to be used.

 

You can add something like this on the end

www.websitehere.com/board.php?forum_num=test&redirect=post

 

Then check at the start of the script if redirect has been set and then act accordingly. Never take the parameter directly from the URL and use it in an include as this is a security issue but check what the redirect parameter can be then redirect manually. Here's an example...

switch ($_GET['redirect']) {
  case 'post':header('post.php');exit;break;
}

Link to comment
Share on other sites

If you want to pass the parameters on the URL as well to the redirect try something like this...

 

$url=$_SERVER['REQUEST_URI'];
switch ($_GET['redirect']) {
  case 'post':$url=stripRedirect('post',$url);header('post.php'.$url);exit;break;
}

function stripRedirect($txt,$url) {
  $tmp=str_replace('redirect='.$txt,'',$url);
  return trim($tmp,'&/?');
}

 

Something like that although that will need some tweaking - but it gives the general idea.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.