Jump to content


Photo

php change address bar text


  • Please log in to reply
6 replies to this topic

#1 perezf

perezf
  • Members
  • PipPipPip
  • Advanced Member
  • 301 posts
  • LocationFort Lauderdale

Posted 29 March 2006 - 08:08 PM

how is it possible to change what is displayed in the address bar
for instance from [site.com/games.php] to a [site.com/?page=games]

#2 perezf

perezf
  • Members
  • PipPipPip
  • Advanced Member
  • 301 posts
  • LocationFort Lauderdale

Posted 29 March 2006 - 08:22 PM

can anyone help me at all


#3 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 29 March 2006 - 08:29 PM

Yes you can do it. You will still have to make both pages

you will have to have at least one page show. like

[a href=\"http://site.com/index.php?page=games\" target=\"_blank\"]http://site.com/index.php?page=games[/a]

The on the index page all you need to do is include the page

index.php
<?
include(''.$_GET['page'].'.php');
?>

Ray

#4 perezf

perezf
  • Members
  • PipPipPip
  • Advanced Member
  • 301 posts
  • LocationFort Lauderdale

Posted 29 March 2006 - 08:31 PM

[!--quoteo(post=359800:date=Mar 29 2006, 03:29 PM:name=craygo)--][div class=\'quotetop\']QUOTE(craygo @ Mar 29 2006, 03:29 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Yes you can do it. You will still have to make both pages

you will have to have at least one page show. like

[a href=\"http://site.com/index.php?page=games\" target=\"_blank\"]http://site.com/index.php?page=games[/a]

The on the index page all you need to do is include the page

index.php
<?
include(''.$_GET['page'].'.php');
?>

Ray
[/quote]


im not really understanding what your trying to say

#5 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 29 March 2006 - 08:35 PM

$_GET is a global array that grabs information out of the URL. If someone goes to your site or clicks on a link from your site with the following address: "mysite.com/index.php?page=123" then you're going to find "123" in the variable: $_GET['page'].

So in your index page, you need to handle that:

<?php
if(isset($_REQUEST['page']))
{
    switch($_GET['page'])
    {  
          case "123":
                include("page123.php");
          break;
          case "foo":
                include("foobar.php");
          break;
}
else
    include("main.php");
?>

Does that help? Also, please do not bump your thread 12 minutes after posting a question. Someone will get to it.

Info: PHP Manual


#6 perezf

perezf
  • Members
  • PipPipPip
  • Advanced Member
  • 301 posts
  • LocationFort Lauderdale

Posted 29 March 2006 - 08:41 PM

[!--quoteo(post=359804:date=Mar 29 2006, 03:35 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ Mar 29 2006, 03:35 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
$_GET is a global array that grabs information out of the URL. If someone goes to your site or clicks on a link from your site with the following address: "mysite.com/index.php?page=123" then you're going to find "123" in the variable: $_GET['page'].

So in your index page, you need to handle that:

<?php
if(isset($_REQUEST['page']))
{
    switch($_GET['page'])
    {  
          case "123":
                include("page123.php");
          break;
          case "foo":
                include("foobar.php");
          break;
}
else
    include("main.php");
?>

Does that help? Also, please do not bump your thread 12 minutes after posting a question. Someone will get to it.
[/quote]

im not really understanding on how i can link this code to my links


#7 perezf

perezf
  • Members
  • PipPipPip
  • Advanced Member
  • 301 posts
  • LocationFort Lauderdale

Posted 29 March 2006 - 08:54 PM

is there a tutorial anywhere that would show me step by step




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users