• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

php help

kjavia795

New Member
Hey guys I need a bit of help in php. Basically, a person will be sent to my website with a special id, which will be at the end of the url. So it will be something like http://easymazuma.com/page.php?id=USERNAME

On that page will be a link to another website. Lets say the link is http://xxx.com/

How can I get the username that they came into my site with and have it added to the end of the outgoing url? So if they came to http://easymazuma.com/page.php?id=USERNAME

the link they click should go to http://xxx.com/USERNAME

thx :)
 
you need to carry the id over. use something like...

PHP:
id = $_GET['id'];

that needs to be on the first page they go to. then, when you construct your links for the other pages, you can have something like...

PHP:
echo '<a href="http://url.com/'.$id.'">Site Name</a>';

i hope i understood you r question and that helps. if not, try re-wording it with a little more details possible. good luck.
 
Last edited:
Is this ok for you?
PHP:
<?php
if(isset($_GET['id'])) {
	$url = "http://xxx.com";
	header("Location: ".$url."/". $_GET['id']);
}
?>
 
yeah, i think i may have misunderstood his question. still a little confused, but, Jonny`s code will work if i was to interpret the question another way. so, hopefully one of these works.
 
hmm the first one gave me this error: Parse error: syntax error, unexpected '=' in /home/easymazu/public_html/abcde.php on line 3

the 2nd one goes directly to the page. I want it to be a link that they click on, not directly redirect.

method basically people will go to page.com/?id=theirusername and when they click the link on that page they need to go to page2.com/(INSERTUSERNAMEHERE)
 
There you go.
PHP:
<?php
if(isset($_GET['id'])) {
    $url = "http://xxx.com";
    $uUrl = $url."/".$_GET['id'];
    echo '<a href="$uUrl">$uUrl</a>';
}
?>
 
There you go.
PHP:
<?php
if(isset($_GET['id'])) {
    $url = "http://xxx.com";
    $uUrl = $url."/".$_GET['id'];
    echo '<a href="'.$uUrl.'">'.$uUrl.'</a>';
}
?>
 
Make sure id is a number.

PHP:
<?php
$id = $_POST['id'];

if (is_numeric($id)) {
   
   if (isset($id)) {
      $url = "http://xxx.com";
      $uUrl = $url."/".$_GET['id'];
      echo '<a href="'.$uUrl.'">'.$uUrl.'</a>';
   }
} else {
   echo "Die: Hacking attempt.";
   exit;
}
?>
 
Last edited:
Back
Top