Need Help With URL

Discussion in 'PHP' started by christopher.mah, May 17, 2009.

  1. #1
    I have this code so far

    	<td>Referral:(optional)</td>
    <td><input id='referral' type='text' name='6' value='{$_SERVER['REQUEST_URI']}' class='input'></td>
    	
    PHP:
    And I want the value to show the Referral Username.
    Right now i get this in the textbox which is normal

    /register.php/USERNAME.html

    how would i get the value of the textbox to show just the USERNAME and ignore /register.php/ and .html
     
    christopher.mah, May 17, 2009 IP
  2. Sky AK47

    Sky AK47 Member

    Messages:
    298
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    45
    #2
    $var = $_SERVER['REQUEST_URI'];
    	$var = explode("/", $var);
    	$var = explode(".html", $var[2]);
    	echo $var[0];
    PHP:
    But wouldn't it be easier to use GET? register.php?ref=USERNAME
     
    Sky AK47, May 17, 2009 IP
  3. christopher.mah

    christopher.mah Peon

    Messages:
    351
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    but how would i use the GET?
    sorry im not strong with php
     
    christopher.mah, May 17, 2009 IP
  4. Sky AK47

    Sky AK47 Member

    Messages:
    298
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    45
    #4
    h*tp://www.w3schools.com/PHP/php_get.asp
    register.php?ref=USERNAME, you can call ref anything you want, and the variable would be $_GET['ref'] or anything you want to use.
     
    Sky AK47, May 17, 2009 IP
  5. christopher.mah

    christopher.mah Peon

    Messages:
    351
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    thanks for the help i fixed it
     
    christopher.mah, May 17, 2009 IP