Jump to content

Archived

This topic is now archived and is closed to further replies.

Lessur

?page=

Recommended Posts

I have seen many sites with somethig like:

www.domainhere.com/?page=news

And then another page like www.domainhere.com/?page=other

How can I do that?  ???

Share this post


Link to post
Share on other sites
They are get queries
used in universal pages or the like
All it means is
http://www.whatever.com
that is the domain name
http://www.whatever.com/index.php
that is the filename that you are on, the homepage in this case
http://www.whatever.com/index.php?name=west&born=1983
That is the domain name, followed by the page they are on
the question mark ends hte actual url information and starts variable information
there just php variables, this becomes
$name = "west";
$born = 1983;
what would be that those values are assigned to those variables on the next page USING the get command
$_GET['name']
$_GET['born']
the first variable contains "west" the second containes 1983
Then you have other symbols for other things, if the variables values contain spaces, you see + for every space, if there are other special characters they automatically get url encoded.

Share this post


Link to post
Share on other sites
Like you can take and do this with like 20 url's
and have 1 page handle all of those url's based on the contents of the get variables, and have it use the location header to redirect them to the appropriate pages, it can severely cut down on the number of pages on your server.

Share this post


Link to post
Share on other sites
I dont really understand.  I am talking about for example a site like http://thesmurk.net/.  When you click on "Flash" for example the new address is http://thesmurk.net/?page=flash

Share this post


Link to post
Share on other sites
[code]?page=flash[/code]
That simply means as I states
the ? ends the actual url information and starts the variables
the variable page is set to teh word flash
$page = flash;
is how you would do it, or how it would look in php.
this probably tells a redirecting page to send it to the flash version of the site, or could be for something else, or something used in the script to decide whether to activate flash or not.  Could be many reasons.

Share this post


Link to post
Share on other sites
Oh I just checked it,
if it's set to flash it displays the flash elements, if you take it off, the flash elements are x-ed out.

Share this post


Link to post
Share on other sites
or they could be testing the browser for flash, and if it exists it shows that, if not it doesn't, it could be anythign.

Share this post


Link to post
Share on other sites
[quote author=businessman332211 link=topic=102191.msg405273#msg405273 date=1154109356]
[code]?page=flash[/code]
That simply means as I states
the ? ends the actual url information and starts the variables
the variable page is set to teh word flash
$page = flash;
is how you would do it, or how it would look in php.
this probably tells a redirecting page to send it to the flash version of the site, or could be for something else, or something used in the script to decide whether to activate flash or not.  Could be many reasons.
[/quote]

So basically, in another page there is $page = flash; ?  And when you say www.blah.com/?page=flash it goes to the page that has $page = flash;  in it?

Share this post


Link to post
Share on other sites
[quote author=Lessur link=topic=102191.msg405270#msg405270 date=1154109183]
I dont really understand.  I am talking about for example a site like http://thesmurk.net/.  When you click on "Flash" for example the new address is http://thesmurk.net/?page=flash
[/quote]

In your example:

What will happen is that the same page (the one at http://thesmurk.net/) will be loaded. But this time around, a variable will be set in the superglobal array $_GET, with the value "flash".  The script would access this variable by looking at $_GET["page"].

It might use this in a switch statement, e.g.

if(isset($_GET["page"]))
{
switch($_GET["page"])
{
  case "flash":
     .....do some flash stuff.....
  break;
  default:
     .....do something else......
  break;
}
}

Share this post


Link to post
Share on other sites
No that sets the variable.
It means that if you set that,
http://www.domain.com/index.php?page=flash
like if you have in a link
index.php?page=flash
they click on that, on the index.php page if you type out
echo $page;
it's going to say
flash
it just registers the variable with the value for use on the next page.
Even if it's a quick script to see which one was set for redirection.

Share this post


Link to post
Share on other sites
exacly like he states above.  With that example, that is exactly how I was meaning for redirect. 

Share this post


Link to post
Share on other sites
quick and simple code for you.
EX URL: http://example.com/index.php?id=1
if(isset($_GET['id'])){
$id=$_GET['id'];
}else{
$id=0; //this is not very necessary//
}
switch($id){
case 1:
//EX: This is were the url goes to.//
include("news.php");
break;
case 2:
//EX: Include about//
include("about.php");
break;
default;
//EX : Include home page//
include("home.php");
}

FOR Words just put case 'word': //Make sure it has " ' " because it prob will screw up with " not sure its been a while

Share this post


Link to post
Share on other sites
Would that code code into my index.php (My home page.)  or Shoudl I make that code index.php and the old index.php index2.php?  Hehe, sorry but Im a newb when it comes to php  :'(

Share this post


Link to post
Share on other sites
It has to be applied in the form of a link, there has to be some point when someone clicks on a link to have hte query string there.
You could have a front page, that says click here for flash version, or here for non flash version
non flash version has no code
the other is like
<a href="index.php?page=flash">Flash Version</a>
That sends hte variable
$page = flash
across to the other page, so you can activate the flash or whatever
or you can send to another redirect page
and have
if ($_GET['page'] == "flash") {
$page = "indexwithflash.php";
header('Location: ' . $page);
}else {
$page = "index.php"; // regular index page with no flash
header('Location: ' . $page);
}
Even still you can do something like have the variable disable and enable flash as necessary,

Share this post


Link to post
Share on other sites
[quote author=Lessur link=topic=102191.msg405287#msg405287 date=1154110700]
Would that code code into my index.php (My home page.)  or Shoudl I make that code index.php and the old index.php index2.php?  Hehe, sorry but Im a newb when it comes to php  :'(
[/quote]

What is it that you're actually trying to do?

Share this post


Link to post
Share on other sites
I want to have something like www.domain.com/?page=pagehere.

For example, if I went to my domain.  It would come up on index.php.  And say I have a link to info.  I want to be able to make that link www.domain.com/?page=info.  I also have a link to flash, with, there a link to each persons flash.  I wnat to be able to say www.domain.com/?page=flash&user=usernameofuser .  How can I do such a thing?  I already have all the pages.

Share this post


Link to post
Share on other sites
That's not going to happen, being limited to just passing get variables.  You need some kind of login if you don't already have one, plus either sessions or cookies.  On top of that you need to pass the variables necessary, and even in this particular situation passing get variables between urls for this, would be pointless, you should automatically generate the url's via db interacting into the session variables, when they first login, and pass that information from page to page, this will save you a lot of time, and a lot of headaches, and be a little more secure. 

Share this post


Link to post
Share on other sites

×

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.